Skip to content

Commit

Permalink
1st commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tanaikech committed Apr 24, 2017
0 parents commit a44a6ff
Show file tree
Hide file tree
Showing 20 changed files with 4,343 additions and 0 deletions.
8 changes: 8 additions & 0 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright (c) 2017 Kanshi TANAIKE

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1,453 changes: 1,453 additions & 0 deletions README.md

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
Package main (doc.go) :
This is a CLI tool to execute Google Apps Script (GAS) on a terminal.
Will you want to develop GAS on your local PC? Generally, when we develop GAS, we have to login to Google using own browser and develop it on the Script Editor. Recently, I have wanted to have more convenient local-environment for developing GAS. So I created this "ggsrun". The main work is to execute GAS on local terminal and retrieve the results from Google.
# Features of "ggsrun" are as follows.
1. Develops GAS using your terminal and text editor which got accustomed to using.
2. Executes GAS by giving values to your script.
3. Executes GAS made of CoffeeScript.
4. Downloads spreadsheet, document and presentation, while executes GAS, simultaneously.
5. Creates, updates and backs up project with GAS.
6. Downloads files from Google Drive and Uploads files to Google Drive.
You can see the release page https://github.com/tanaikech/ggsrun/releases
# Google API
ggsrun uses Execution API, Web Apps and Drive API on Google. About how to install ggsrun, please check my github repository.
https://github.com/tanaikech/ggsrun/
You can read the detail information there.
---------------------------------------------------------------
# How to Execute Google Apps Script Using ggsrun
When you have the configure file `ggsrun.cfg`, you can execute GAS. If you cannot find it, please download `client_secret.json` and run
$ ggsrun auth
In the case of using Execution API,
$ ggsrun e1 -s sample.gs
If you want to execute a function except for `main()` of default, you can use an option like `-f foo`. This command `exe1` can be used to execute a function on project.
$ ggsrun e1 -f foo
$ ggsrun e2 -s sample.gs
At `e2`, you cannot select the executing function except for `main()` of default.
`e1`, `e2` and `-s` mean using Execution API and GAS script file name, respectively. Sample codes which are shown here will be used Execution API. At this time, the executing function is `main()`, which is a default, in the script.
In the case of using Web Apps,
$ ggsrun w -s sample.gs -p password -u [ WebApps URL ]
`w` and `-p` mean using Web Apps and password you set at the server side, respectively. Using `-u` it imports Web Apps URL like `-u https://script.google.com/macros/s/#####/exec`.
---------------------------------------------------------------
*/
package main
246 changes: 246 additions & 0 deletions ggsrun.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
// Package main (ggsrun.go) :
// This file is included all commands and options.
package main

import (
"os"

"github.com/urfave/cli"
)

// main : main function
func main() {
app := cli.NewApp()
app.Name = appname
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.0.0"
app.Commands = []cli.Command{
{
Name: "exe1",
Aliases: []string{"e1"},
Usage: "Updates project and Executes the function in the project.",
Description: "In this mode, an access token is required.",
Action: exeAPIWithout,
Flags: []cli.Flag{
cli.StringFlag{
Name: "scriptid, i",
Usage: "Script ID of project on Google Drive",
},
cli.StringFlag{
Name: "scriptfile, s",
Usage: "GAS file (.gs, .gas, .js, .coffee) on local PC",
},
cli.StringFlag{
Name: "function, f",
Usage: "Function name which is executed. Default is '" + deffuncwithout + "'.",
},
cli.StringFlag{
Name: "value, v",
Usage: "Give a value to the function which is executed.",
},
cli.BoolFlag{
Name: "backup, b",
Usage: "Backup project with script ID you set as a file.",
},
cli.BoolFlag{
Name: "onlyresult, r",
Usage: "Display only 'result' in JSON results",
},
cli.BoolFlag{
Name: "jsonparser, j",
Usage: "Display results by JSON parser",
},
},
},
{
Name: "exe2",
Aliases: []string{"e2"},
Usage: "Uploads GAS and Executes the script using Execution API.",
Description: "In this mode, an access token is required.",
Action: exeAPIWith,
Flags: []cli.Flag{
cli.StringFlag{
Name: "scriptid, i",
Usage: "Script ID of project on Google Drive",
},
cli.StringFlag{
Name: "scriptfile, s",
Usage: "GAS file (.gs, .gas, .js, .coffee) on local PC",
},
cli.StringFlag{
Name: "function, f",
Usage: "Function name of server for executing GAS. Default is '" + deffuncserv + "'. If you change the server, use this.",
},
cli.StringFlag{
Name: "value, v",
Usage: "Give a value to the function of GAS script which is executed.",
},
cli.StringFlag{
Name: "stringscript, ss",
Usage: "GAS script as strings.",
},
cli.BoolFlag{
Name: "foldertree, t",
Usage: "Display a folder tree on Google Drive as an array.",
},
cli.BoolFlag{
Name: "convert, conv",
Usage: "[Experiment] Download file using byte slice data. Use with '-v [File ID]'.",
},
cli.BoolFlag{
Name: "log, l",
Usage: "Record access log.",
},
cli.BoolFlag{
Name: "onlyresult, r",
Usage: "Display only 'result' in JSON results",
},
cli.BoolFlag{
Name: "jsonparser, j",
Usage: "Display results by JSON parser",
},
},
},
{
Name: "webapps",
Aliases: []string{"w"},
Usage: "Uploads GAS and Executes the script without OAuth using Web Apps.",
Description: "In this mode, an access token is NOT required.",
Action: webAppsWith,
Flags: []cli.Flag{
cli.StringFlag{
Name: "url, u",
Usage: "URL for using Web Apps.",
},
cli.StringFlag{
Name: "scriptfile, s",
Usage: "GAS file (.gs, .gas, .js, .coffee) on local PC",
},
cli.StringFlag{
Name: "value, v",
Usage: "Give a value to the function of GAS script which is executed.",
},
cli.StringFlag{
Name: "password, p",
Usage: "Password to use Web Apps (if you have set)",
},
cli.BoolFlag{
Name: "log, l",
Usage: "Not record access log. No this option means 'Record log'.",
},
cli.BoolFlag{
Name: "onlyresult, r",
Usage: "Display only 'result' in JSON results",
},
cli.BoolFlag{
Name: "jsonparser, j",
Usage: "Display results by JSON parser",
},
},
},
{
Name: "download",
Aliases: []string{"d"},
Usage: "Downloads files from Google Drive.",
Description: "In this mode, an access token is required.",
Action: downloadFiles,
Flags: []cli.Flag{
cli.StringFlag{
Name: "fileid, i",
Usage: "File ID on Google Drive",
},
cli.StringFlag{
Name: "filename, f",
Usage: "File Name on Google Drive",
},
cli.StringFlag{
Name: "extension, e",
Usage: "Extension (File format of downloaded file)",
},
cli.BoolFlag{
Name: "rawdata, r",
Usage: "Save a project with GAS scripts as raw data (JSON data).",
},
cli.BoolFlag{
Name: "jsonparser, j",
Usage: "Display results by JSON parser",
},
},
},
{
Name: "upload",
Aliases: []string{"u"},
Usage: "Uploads files to Google Drive.",
Description: "In this mode, an access token is required.",
Action: uploadFiles,
Flags: []cli.Flag{
cli.StringFlag{
Name: "filename, f",
Usage: "File Name on local PC",
},
cli.StringFlag{
Name: "parentfolderid, p",
Usage: "Folder ID of parent folder on Google Drive",
},
cli.StringFlag{
Name: "projectname, pn",
Usage: "Upload several GAS scripts as a project.",
},
cli.BoolFlag{
Name: "noconvert, nc",
Usage: "If you don't want to convert file to Google Apps format.",
},
cli.BoolFlag{
Name: "jsonparser, j",
Usage: "Display results by JSON parser",
},
},
},
{
Name: "filelist",
Aliases: []string{"ls"},
Usage: "Outputs a file list on Google Drive.",
Description: "In this mode, an access token is required.",
Action: showFileList,
Flags: []cli.Flag{
cli.StringFlag{
Name: "searchbyname, sn",
Usage: "Search file using File Name. Output File ID.",
},
cli.StringFlag{
Name: "searchbyid, si",
Usage: "Search file using File ID. Output File Name.",
},
cli.BoolFlag{
Name: "stdout, s",
Usage: "Output all file list to standard output.",
},
cli.BoolFlag{
Name: "file, f",
Usage: "Output all file list to a JSON file.",
},
cli.BoolFlag{
Name: "jsonparser, j",
Usage: "Display results by JSON parser",
},
},
},
{
Name: "auth",
Usage: "Retrieve access and refresh tokens. If you changed scopes, please use this.",
Description: "In this mode, 'client_secret.json' and Scopes are required.",
Action: reAuth,
Flags: []cli.Flag{
cli.IntFlag{
Name: "port, p",
Usage: "Port number of temporal web server for retrieving authorization code.",
Value: 8080,
},
},
},
}
app.CommandNotFound = commandNotFound
app.Run(os.Args)
}
Loading

0 comments on commit a44a6ff

Please sign in to comment.