Skip to content

Commit

Permalink
Updated to v1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
tanaikech committed May 28, 2017
1 parent 9af639f commit 1e773cf
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 4 deletions.
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,21 @@ $ ggsrun auth
- At the default, there are 6 scopes. If you want to change the scopes, please modify ``ggsrun.cfg`` and run ``$ ggsrun auth``.
- You notice that ``script_id`` has no data. Don't worry. This is explained below.

<a name="environmentvariable"></a>
##### Environment Variable <sup><font color="Red">NEW! (v1.2.1)</font></sup>
**``ggsrun.cfg`` can be read using the environment variable.**

- If the environment variable (**``GGSRUN_CFG_PATH``**) is set, ggsrun.cfg is read using it.
- If it is not set, ggsrun.cfg is read from the current working directory. This is as has been the way until now.

For example, in the case of bash, please add a following code to ``.bashrc``.

~~~bash
export GGSRUN_CFG_PATH=~/ggsrun/
~~~

When you want to run ``$ ggsrun auth`` to authorize, please run under a directory with ``client_secret.json``. ``ggsrun.cfg`` is created to the current working directory.

#### 5. <u>Run ggsrun</u>
Please create ``sample.gs`` with following script.

Expand Down Expand Up @@ -995,7 +1010,7 @@ $ ggsrun ud -p [Project ID on Google Drive] -f [script .gs, .gas, .htm, .html]
If it is not used ``-p``, the project ID is used the script ID in "ggsrun.cfg". When a script for updating is the same to a script name in the project, it is overwritten. Other scripts in the project is not changed. So this can be also used for updating a script in the project.

<a name="RevisionFile"></a>
## 11. Retrieve Revision Files
## 11. Retrieve Revision Files <sup><font color="Red">NEW! (v1.2.0)</font></sup>
It retrieves revisions for files on Google Drive.

**Display revision ID list for file ID :**
Expand Down Expand Up @@ -1497,6 +1512,15 @@ If you have any questions and commissions for me, feel free to tell me using e-m
1. Added a command for retrieving revision files on Google Drive. The detail information is [here](#RevisionFile).
2. Some modifications.

* v1.2.1 (May 28, 2017)

1. ggsrun.cfg got be able to be read using the environment variable.
- If the environment variable (**``GGSRUN_CFG_PATH``**) is set, ggsrun.cfg is read using it.
- If it is not set, ggsrun.cfg is read from the current working directory. This is as has been the way until now.
- This is the response for some requests.
- This incofmation was added to [here](#environmentvariable).


## Server
* v1.0.0 (April 24, 2017)

Expand Down
2 changes: 1 addition & 1 deletion ggsrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func main() {
app.Author = "tanaike [ https://github.com/tanaikech/ggsrun ] "
app.Email = "[email protected]"
app.Usage = "Executes Google Apps Script (GAS) on Google and Feeds Back Results."
app.Version = "1.2.0"
app.Version = "1.2.1"
app.Commands = []cli.Command{
{
Name: "exe1",
Expand Down
2 changes: 1 addition & 1 deletion init.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

// GgsrunIni :
func (a *AuthContainer) ggsrunIni(c *cli.Context) *AuthContainer {
if cfgdata, err := ioutil.ReadFile(filepath.Join(a.InitVal.workdir, cfgFile)); err == nil {
if cfgdata, err := ioutil.ReadFile(filepath.Join(a.InitVal.cfgdir, cfgFile)); err == nil {
err = json.Unmarshal(cfgdata, &a.GgsrunCfg)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: Format error of '%s'. ", cfgFile)
Expand Down
15 changes: 15 additions & 0 deletions materials.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package main

import (
"math"
"os"
"path/filepath"
"regexp"
"time"
Expand All @@ -23,6 +24,7 @@ const (

clientsecretFile = "client_secret.json"
cfgFile = "ggsrun.cfg"
cfgpathenv = "GGSRUN_CFG_PATH"

deffuncserv = "ggsrunif.ExecutionApi"
deffuncwith = "main"
Expand All @@ -42,6 +44,7 @@ const (
type InitVal struct {
pstart time.Time
workdir string
cfgdir string
update bool
log bool
Port int
Expand Down Expand Up @@ -247,6 +250,14 @@ func defAuthContainer(c *cli.Context) *AuthContainer {
if err != nil {
panic(err)
}
if c.Command.Names()[0] == "auth" {
a.InitVal.cfgdir = a.InitVal.workdir
} else {
a.InitVal.cfgdir = os.Getenv(cfgpathenv)
if a.InitVal.cfgdir == "" {
a.InitVal.cfgdir = a.InitVal.workdir
}
}
a.Param.Function = c.String("function")
a.InitVal.log = c.Bool("log")
a.InitVal.Port = defPort
Expand Down Expand Up @@ -306,6 +317,10 @@ func defExecutionContainerWebApps() *ExecutionContainer {
if err != nil {
panic(err)
}
e.InitVal.cfgdir = os.Getenv(cfgpathenv)
if e.InitVal.cfgdir == "" {
e.InitVal.cfgdir = e.InitVal.workdir
}
return e
}

Expand Down
2 changes: 1 addition & 1 deletion oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (a *AuthContainer) reAuth() {
// makecfgfile :
func (a *AuthContainer) makecfgfile() {
btok, _ := json.MarshalIndent(a.GgsrunCfg, "", "\t")
ioutil.WriteFile(filepath.Join(a.InitVal.workdir, cfgFile), btok, 0777)
ioutil.WriteFile(filepath.Join(a.InitVal.cfgdir, cfgFile), btok, 0777)
}

// getAtoken : Retrieves accesstoken from refreshtoken.
Expand Down

0 comments on commit 1e773cf

Please sign in to comment.