Skip to content

Commit

Permalink
Updated to v1.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
tanaikech committed Jan 2, 2018
1 parent e458e96 commit 126d0f6
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 37 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ Congratulation! You got ggsrun!
1. [Executes GAS with Values and Downloads File](help/README.md#ExecutesGASwithValuesandDownloadsFile)
1. [Executes Existing Functions on Project](help/README.md#ExecutesExistingFunctionsonProject)
1. [Download Files](help/README.md#DownloadFiles)
1. [How to Download Container-Bound Scripts](help/README.md#DownloadBoundScript) <sup><font color="Red">NEW! (v1.3.4)</font></sup>

1. [Upload Files](help/README.md#UploadFiles)
1. [Show File List](help/README.md#ShowFileList)
1. [Search Files](help/README.md#SearchFiles)
Expand Down
10 changes: 7 additions & 3 deletions 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.3.3"
app.Version = "1.3.4"
app.Commands = []cli.Command{
{
Name: "exe1",
Expand Down Expand Up @@ -149,15 +149,19 @@ func main() {
Flags: []cli.Flag{
cli.StringFlag{
Name: "fileid, i",
Usage: "File ID on Google Drive",
Usage: "File ID on Google Drive. Using file ID, you can download all files except for bound scripts.",
},
cli.StringFlag{
Name: "filename, f",
Usage: "File Name on Google Drive",
},
cli.StringFlag{
Name: "projectid, pi",
Usage: "Project ID of bound scripts of Google Sheets, Docs, or Forms file",
Usage: "Project ID of 'bound scripts' of Google Sheets, Docs, or Forms file. Please use this for downloading 'bound scripts'.",
},
cli.StringFlag{
Name: "boundscriptname, bn",
Usage: "This is used for the option of 'projectid'. Using this option, when you download the 'bound scripts', you can give the filename.",
},
cli.StringFlag{
Name: "extension, e",
Expand Down
23 changes: 15 additions & 8 deletions help/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -891,13 +891,17 @@ You can convert only from Google Docs Files (spreadsheet, slide, documentation a
You can download the project by the following command.

~~~bash
$ ggsrun d -pi project_id
$ ggsrun d -pi project_id -bn filename
~~~

- pi: project_id
- bn: filename which is used for downloading.

**Limitation :**

- The file information of container-bound scripts cannot be retrieved by Drive API. So the filename cannot be retrieved from the project ID.
- Prefix of filename of the downloaded project is the project ID.
- When the option ``bn`` is not used, the prefix of filename of the downloaded project is the project ID.
- When the option ``bn`` is used, the prefix of filename of the downloaded project is the filename you gave.

### Help
~~~
Expand All @@ -912,12 +916,13 @@ DESCRIPTION:
In this mode, an access token is required.
OPTIONS:
--fileid value, -i value File ID on Google Drive
--filename value, -f value File Name on Google Drive
--projectid value, --pi value Project ID of bound scripts of Google Sheets, Docs, or Forms file
--extension value, -e value Extension (File format of downloaded file)
--rawdata, -r Save a project with GAS scripts as raw data (JSON data).
--jsonparser, -j Display results by JSON parser
--fileid value, -i value File ID on Google Drive. Using file ID, you can download all files except for bound scripts.
--filename value, -f value File Name on Google Drive
--projectid value, --pi value Project ID of 'bound scripts' of Google Sheets, Docs, or Forms file. Please use this for downloading 'bound scripts'.
--boundscriptname value, --bn value This is used for the option of 'projectid'. Using this option, when you download the 'bound scripts', you can give the filename.
--extension value, -e value Extension (File format of downloaded file)
--rawdata, -r Save a project with GAS scripts as raw data (JSON data).
--jsonparser, -j Display results by JSON parser
~~~

<a name="UploadFiles"></a>
Expand Down Expand Up @@ -1154,6 +1159,8 @@ When existing project is overwritten by a script with an unique filename, all sc

In this demonstration, scripts in a project is intaractively rearranged. After rearranging, HTML file is the top of scripts. So GS file of 2nd script is opened as a default. When GS is the top of scripts, it will be opened as the default.

### Add-on using Google Apps Script
If you want to use add-on created by Google Apps Script. Please check [here](https://github.com/tanaikech/RearrangeScripts).

<a name="ModifyManifests"></a>
## 13. Modify Manifests
Expand Down
10 changes: 10 additions & 0 deletions help/UpdateHistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ ggsrun
1. Some modifications.


* v1.3.4 (January 2, 2018)

1. Added new option for downloading 'bound-scripts' of Google Sheets, Docs, or Forms file.
- When the bound-scripts are downloaded, the project name cannot be retrieved because Drive API cannot be used for the bound-scripts. So when the bound-scripts are downloaded, the project ID had been used previously. Such filename is not easily to be seen. By this additional option, users can give the filename when it downloads the bound-scripts.
- The usage is [here](README.md#DownloadBoundScript)
1. Removed a bug.
- When a project is downloaded, script ID in the project is added to the top of each downloaded script as a comment. There was a problem at the character using for the comment out. This was modified.

**You can read "How to install" at [here](https://github.com/tanaikech/ggsrun/blob/master/README.md#How_to_Install).**

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

Expand Down
5 changes: 3 additions & 2 deletions materials.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,9 @@ func (a *AuthContainer) defDownloadContainer(c *cli.Context) *utl.FileInf {
}
return id
}(c),
WantExt: c.String("extension"),
WantName: c.String("filename"),
BoundScriptName: c.String("boundscriptname"),
WantExt: c.String("extension"),
WantName: c.String("filename"),
}
return p
}
Expand Down
61 changes: 37 additions & 24 deletions utl/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,29 @@ const (

// FileInf : File information for downloading and uploading
type FileInf struct {
Accesstoken string `json:"-"`
DlMime string `json:"-"`
MimeType string `json:"mimeType,omitempty"`
Workdir string `json:"-"`
PstartTime time.Time `json:"-"`
WantExt string `json:"-"`
WantName string `json:"-"`
WebLink string `json:"webContentLink,omitempty"`
WebView string `json:"webViewLink,omitempty"`
SearchByName string `json:"-"`
SearchByID string `json:"-"`
FileID string `json:"id,omitempty"`
ProjectID string `json:"project_id,omitempty"`
RevisionID string `json:"revisionid,omitempty"`
FileName string `json:"name,omitempty"`
SaveName string `json:"saved_file_name,omitempty"`
Parents []string `json:"parents,omitempty"`
UpFilename []string `json:"upload_file_name,omitempty"`
UpFileID []string `json:"uid,omitempty"`
UppedFiles []uploadedFile `json:"uploaded_files,omitempty"`
TotalEt float64 `json:"TotalElapsedTime,omitempty"`
Msgar []string `json:"message,omitempty"`
Accesstoken string `json:"-"`
DlMime string `json:"-"`
MimeType string `json:"mimeType,omitempty"`
Workdir string `json:"-"`
PstartTime time.Time `json:"-"`
WantExt string `json:"-"`
WantName string `json:"-"`
WebLink string `json:"webContentLink,omitempty"`
WebView string `json:"webViewLink,omitempty"`
SearchByName string `json:"-"`
SearchByID string `json:"-"`
FileID string `json:"id,omitempty"`
ProjectID string `json:"project_id,omitempty"`
BoundScriptName string `json:"_"`
RevisionID string `json:"revisionid,omitempty"`
FileName string `json:"name,omitempty"`
SaveName string `json:"saved_file_name,omitempty"`
Parents []string `json:"parents,omitempty"`
UpFilename []string `json:"upload_file_name,omitempty"`
UpFileID []string `json:"uid,omitempty"`
UppedFiles []uploadedFile `json:"uploaded_files,omitempty"`
TotalEt float64 `json:"TotalElapsedTime,omitempty"`
Msgar []string `json:"message,omitempty"`
}

// dlError : Error messages.
Expand Down Expand Up @@ -156,7 +157,15 @@ func (p *FileInf) saveScript(data []byte, c *cli.Context) *FileInf {
}
return eext
}(p.WantExt, e.Type)
src := fmt.Sprintf("// Script ID in Project = %s \n%s", e.ID, e.Source)
var src string
switch e.Type {
case "server_js":
src = fmt.Sprintf("// Script ID in Project = %s \n%s", e.ID, e.Source)
case "html":
src = fmt.Sprintf("<!-- Script ID in Project = %s -->\n%s", e.ID, e.Source)
default:
src = fmt.Sprintf("%s", e.Source)
}
ioutil.WriteFile(filepath.Join(p.Workdir, saveName), []byte(src), 0777)
p.Msgar = append(p.Msgar, fmt.Sprintf("Script was downloaded as '%s'.", saveName))
}
Expand Down Expand Up @@ -195,7 +204,11 @@ func (p *FileInf) Downloader(c *cli.Context) *FileInf {
}
} else {
if len(p.ProjectID) > 0 && p.MimeType == "" {
p.FileName = p.ProjectID
if p.BoundScriptName != "" {
p.FileName = p.BoundScriptName
} else {
p.FileName = p.ProjectID
}
p.MimeType = "application/vnd.google-apps.script"
p, body = p.writeFile(sdownloadurl + p.ProjectID + "&format=json")
p.saveScript(body, c)
Expand Down

0 comments on commit 126d0f6

Please sign in to comment.