Skip to content

Commit

Permalink
Updated to v1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tanaikech committed Dec 27, 2018
1 parent 29f833d commit ade40ad
Show file tree
Hide file tree
Showing 12 changed files with 670 additions and 67 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ ggsrun

<a name="Overview"></a>
# Overview
This is a CLI tool to execute Google Apps Script (GAS) on a terminal.
This is a CLI tool to execute Google Apps Script (GAS) on a terminal. Also this CLI tool can be used for managing files in Google Drive for OAuth2 and Service Account.

<a name="Demo"></a>
# Demo
![](help/images/spreadsheetdemo.gif)

<a name="Description"></a>
# Description
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.
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. Furthermore, this tool can be also used for managing files in own Google Drive (OAuth2) and Google Drive for Service Account.

Features of "ggsrun" are as follows.

Expand All @@ -32,6 +32,9 @@ Features of "ggsrun" are as follows.
1. **[Rearranges scripts in project.](help/README.md#rearrangescripts)** <sup><font color="Red">Updated! (v1.4.0)</font></sup>
1. **[Modifies Manifests in project.](help/README.md#modifymanifests)**
1. **[Seach files in Google Drive using search query and regex](help/README.md#searchfilesusingregex)** <sup><font color="Red">Updated! (v1.6.0)</font></sup>
1. **[Manage Permissions of files](help/README.md#managepermissions)** <sup><font color="Red">Updated! (v1.7.0)</font></sup>
1. **[Get Drive Information.](help/README.md#getdriveinformation)** <sup><font color="Red">Updated! (v1.7.0)</font></sup>
1. **[ggsrun got to be able to be used by not only OAuth2, but also Service Account.](help/README.md#useserviceaccount)** <sup><font color="Red">Updated! (v1.7.0)</font></sup>

<a name="howtoinstall"></a>
# How to Install
Expand Down Expand Up @@ -94,6 +97,11 @@ Please reauthorize to include a new scope to the access token as follows.

Completed!

<a name="from170"></a>
# From version 1.7.0, ggsrun can access to Google Drive using Service Account. <sup><font color="Red">Updated! (v1.7.0)</font></sup>
ggsrun can access to Google Drive using [Service Account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount). When OAuth2 is used, you can see the files and folders in own Google Drive. When Service Account is used, you can see them in Google Drive for Service Account. Namely, the Drive for OAuth2 is different from that for Service Account. Please be careful this. And when Service Account is used, there are what it can do and what it can't do. About them, please read [here](help/README.md#useserviceaccount).


# How to use ggsrun
1. [Executes GAS and Retrieves Result Values](help/README.md#executesgasandretrievesresultvalues)
1. [Executes GAS with Values and Retrieves Feedbacked Values](help/README.md#executesgaswithvaluesandretrievesfeedbackedvalues)
Expand All @@ -110,6 +118,9 @@ Completed!
1. [Rearrange Script in Project](help/README.md#rearrangescripts)
1. [Modify Manifests](help/README.md#modifymanifests)
1. [Seach Files using Query and Regex](help/README.md#searchfilesusingregex)
1. [Manage Permissions of files](#managepermissions)
1. [Get Drive Information.](#getdriveinformation)
1. [ggsrun got to be able to be used by not only OAuth2, but also Service Account.](#useserviceaccount)

# Applications
1. [For Sublime Text](help/README.md#demosublime)
Expand Down
8 changes: 7 additions & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ Will you want to develop GAS on your local PC? Generally, when we develop GAS, w
12. Modifies Manifests in project.
13. Seach files in Google Drive using search query and regex
13. Seach files in Google Drive using search query and regex.
14. Manage Permissions of files.
15. Get Drive Information.
16. ggsrun got to be able to be used by not only OAuth2, but also Service Account from v1.7.0.
You can see the release page https://github.com/tanaikech/ggsrun/releases
Expand Down
99 changes: 97 additions & 2 deletions ggsrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ func main() {
app.Name = appname
app.Author = "Tanaike [ https://github.com/tanaikech/ggsrun ] "
app.Email = "[email protected]"
app.Usage = "This is an application of Google Drive and Google Apps Script (GAS)."
app.Version = "1.6.0"
app.Usage = "This is a CLI application for managing Google Drive and Google Apps Script (GAS)."
app.Version = "1.7.0"
app.Commands = []cli.Command{
{
Name: "exe1",
Expand Down Expand Up @@ -159,6 +159,10 @@ func main() {
Name: "extension, e",
Usage: "Extension (File format of downloaded file)",
},
cli.StringFlag{
Name: "mimetype, m",
Usage: "mimeType (You can retrieve only files with the specific mimeType, when files are downloaded from a folder.) ex. '-m \"mimeType1,mimeType2\"'",
},
cli.BoolFlag{
Name: "rawdata, r",
Usage: "Save a project with GAS scripts as raw data (JSON data).",
Expand Down Expand Up @@ -187,6 +191,10 @@ func main() {
Name: "jsonparser, j",
Usage: "Display results by JSON parser",
},
cli.StringFlag{
Name: "serviceaccount, sa",
Usage: "Value is filename and path of credentials.json which was retrieved by creating Service Account.",
},
},
},
{
Expand Down Expand Up @@ -242,6 +250,10 @@ func main() {
Name: "jsonparser, j",
Usage: "Display results by JSON parser",
},
cli.StringFlag{
Name: "serviceaccount, sa",
Usage: "Value is filename and path of credentials.json which was retrieved by creating Service Account.",
},
},
},
{
Expand Down Expand Up @@ -312,6 +324,10 @@ func main() {
Name: "jsonparser, j",
Usage: "Display results by JSON parser",
},
cli.StringFlag{
Name: "serviceaccount, sa",
Usage: "Value is filename and path of credentials.json which was retrieved by creating Service Account.",
},
},
},
{
Expand Down Expand Up @@ -341,6 +357,10 @@ func main() {
Name: "jsonparser, j",
Usage: "Display results by JSON parser",
},
cli.StringFlag{
Name: "serviceaccount, sa",
Usage: "Value is filename and path of credentials.json which was retrieved by creating Service Account.",
},
},
},
{
Expand All @@ -366,6 +386,81 @@ func main() {
Name: "jsonparser, j",
Usage: "Display results by JSON parser",
},
cli.StringFlag{
Name: "serviceaccount, sa",
Usage: "Value is filename and path of credentials.json which was retrieved by creating Service Account.",
},
},
},
{
Name: "permissions",
Aliases: []string{"p"},
Usage: "Manage file permissions.",
Description: "In this mode, an access token is required.",
Action: managePermissions,
Flags: []cli.Flag{
cli.StringFlag{
Name: "fileid, fi",
Usage: "Value is file ID. This value is required.",
},
cli.StringFlag{
Name: "permissionid, pi",
Usage: "Value is permission ID. This ID can be retrieved by retrieving permission list.",
},
cli.BoolFlag{
Name: "create, c",
Usage: "Create new permissions.",
},
cli.BoolFlag{
Name: "delete, d",
Usage: "Delete permissions. fileId and permissionId are required.",
},
cli.StringFlag{
Name: "role",
Usage: "The role granted by this permission. While new values may be supported in the future, the following are currently allowed: owner, organizer, fileOrganizer, writer, commenter, reader",
},
cli.StringFlag{
Name: "type",
Usage: "The type of the grantee. Valid values are: user, group, domain, anyone",
},
cli.StringFlag{
Name: "emailaddress, email",
Usage: "The email address of the user or group to which this permission refers.",
},
cli.BoolFlag{
Name: "transferownership, transfer",
Usage: "Whether to transfer ownership to the specified user and downgrade the current owner to a writer. This parameter is required as an acknowledgement of the side effect. (Default: false)",
},
cli.BoolFlag{
Name: "jsonparser, j",
Usage: "Display results by JSON parser",
},
cli.StringFlag{
Name: "serviceaccount, sa",
Usage: "Value is filename and path of credentials.json which was retrieved by creating Service Account.",
},
},
},
{
Name: "driveinformation",
Aliases: []string{"di"},
Usage: "Get drive information.",
Description: "In this mode, an access token is required.",
Action: getDriveInformation,
Flags: []cli.Flag{
cli.StringFlag{
Name: "fields, f",
Usage: "Fields for retrieving files.",
Value: "storageQuota,user",
},
cli.BoolFlag{
Name: "jsonparser, j",
Usage: "Display results by JSON parser",
},
cli.StringFlag{
Name: "serviceaccount, sa",
Usage: "Value is filename and path of credentials.json which was retrieved by creating Service Account.",
},
},
},
{
Expand Down
22 changes: 22 additions & 0 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,28 @@ func searchFilesByQueryAndRegex(c *cli.Context) error {
return nil
}

// managePermissions : Manage permissions.
func managePermissions(c *cli.Context) error {
res := defAuthContainer(c).
ggsrunIni(c).
goauth().
defPermissionsContainer(c).
ManagePermissions()
dispTransferResult(c, res)
return nil
}

// getDriveInformation : Get drive information.
func getDriveInformation(c *cli.Context) error {
res := defAuthContainer(c).
ggsrunIni(c).
goauth().
defDownloadContainer(c).
GetDriveInformation()
dispTransferResult(c, res)
return nil
}

// reAuth : Retrieve tokens again.
func reAuth(c *cli.Context) error {
defAuthContainer(c).
Expand Down
Loading

0 comments on commit ade40ad

Please sign in to comment.