Skip to content

Commit ade40ad

Browse files
committed
Updated to v1.7.0
1 parent 29f833d commit ade40ad

12 files changed

+670
-67
lines changed

README.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ ggsrun
77

88
<a name="Overview"></a>
99
# Overview
10-
This is a CLI tool to execute Google Apps Script (GAS) on a terminal.
10+
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.
1111

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

1616
<a name="Description"></a>
1717
# Description
18-
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.
18+
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.
1919

2020
Features of "ggsrun" are as follows.
2121

@@ -32,6 +32,9 @@ Features of "ggsrun" are as follows.
3232
1. **[Rearranges scripts in project.](help/README.md#rearrangescripts)** <sup><font color="Red">Updated! (v1.4.0)</font></sup>
3333
1. **[Modifies Manifests in project.](help/README.md#modifymanifests)**
3434
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>
35+
1. **[Manage Permissions of files](help/README.md#managepermissions)** <sup><font color="Red">Updated! (v1.7.0)</font></sup>
36+
1. **[Get Drive Information.](help/README.md#getdriveinformation)** <sup><font color="Red">Updated! (v1.7.0)</font></sup>
37+
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>
3538

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

9598
Completed!
9699

100+
<a name="from170"></a>
101+
# From version 1.7.0, ggsrun can access to Google Drive using Service Account. <sup><font color="Red">Updated! (v1.7.0)</font></sup>
102+
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).
103+
104+
97105
# How to use ggsrun
98106
1. [Executes GAS and Retrieves Result Values](help/README.md#executesgasandretrievesresultvalues)
99107
1. [Executes GAS with Values and Retrieves Feedbacked Values](help/README.md#executesgaswithvaluesandretrievesfeedbackedvalues)
@@ -110,6 +118,9 @@ Completed!
110118
1. [Rearrange Script in Project](help/README.md#rearrangescripts)
111119
1. [Modify Manifests](help/README.md#modifymanifests)
112120
1. [Seach Files using Query and Regex](help/README.md#searchfilesusingregex)
121+
1. [Manage Permissions of files](#managepermissions)
122+
1. [Get Drive Information.](#getdriveinformation)
123+
1. [ggsrun got to be able to be used by not only OAuth2, but also Service Account.](#useserviceaccount)
113124

114125
# Applications
115126
1. [For Sublime Text](help/README.md#demosublime)

doc.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ Will you want to develop GAS on your local PC? Generally, when we develop GAS, w
3030
3131
12. Modifies Manifests in project.
3232
33-
13. Seach files in Google Drive using search query and regex
33+
13. Seach files in Google Drive using search query and regex.
34+
35+
14. Manage Permissions of files.
36+
37+
15. Get Drive Information.
38+
39+
16. ggsrun got to be able to be used by not only OAuth2, but also Service Account from v1.7.0.
3440
3541
You can see the release page https://github.com/tanaikech/ggsrun/releases
3642

ggsrun.go

+97-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ func main() {
1414
app.Name = appname
1515
app.Author = "Tanaike [ https://github.com/tanaikech/ggsrun ] "
1616
app.Email = "tanaike@hotmail.com"
17-
app.Usage = "This is an application of Google Drive and Google Apps Script (GAS)."
18-
app.Version = "1.6.0"
17+
app.Usage = "This is a CLI application for managing Google Drive and Google Apps Script (GAS)."
18+
app.Version = "1.7.0"
1919
app.Commands = []cli.Command{
2020
{
2121
Name: "exe1",
@@ -159,6 +159,10 @@ func main() {
159159
Name: "extension, e",
160160
Usage: "Extension (File format of downloaded file)",
161161
},
162+
cli.StringFlag{
163+
Name: "mimetype, m",
164+
Usage: "mimeType (You can retrieve only files with the specific mimeType, when files are downloaded from a folder.) ex. '-m \"mimeType1,mimeType2\"'",
165+
},
162166
cli.BoolFlag{
163167
Name: "rawdata, r",
164168
Usage: "Save a project with GAS scripts as raw data (JSON data).",
@@ -187,6 +191,10 @@ func main() {
187191
Name: "jsonparser, j",
188192
Usage: "Display results by JSON parser",
189193
},
194+
cli.StringFlag{
195+
Name: "serviceaccount, sa",
196+
Usage: "Value is filename and path of credentials.json which was retrieved by creating Service Account.",
197+
},
190198
},
191199
},
192200
{
@@ -242,6 +250,10 @@ func main() {
242250
Name: "jsonparser, j",
243251
Usage: "Display results by JSON parser",
244252
},
253+
cli.StringFlag{
254+
Name: "serviceaccount, sa",
255+
Usage: "Value is filename and path of credentials.json which was retrieved by creating Service Account.",
256+
},
245257
},
246258
},
247259
{
@@ -312,6 +324,10 @@ func main() {
312324
Name: "jsonparser, j",
313325
Usage: "Display results by JSON parser",
314326
},
327+
cli.StringFlag{
328+
Name: "serviceaccount, sa",
329+
Usage: "Value is filename and path of credentials.json which was retrieved by creating Service Account.",
330+
},
315331
},
316332
},
317333
{
@@ -341,6 +357,10 @@ func main() {
341357
Name: "jsonparser, j",
342358
Usage: "Display results by JSON parser",
343359
},
360+
cli.StringFlag{
361+
Name: "serviceaccount, sa",
362+
Usage: "Value is filename and path of credentials.json which was retrieved by creating Service Account.",
363+
},
344364
},
345365
},
346366
{
@@ -366,6 +386,81 @@ func main() {
366386
Name: "jsonparser, j",
367387
Usage: "Display results by JSON parser",
368388
},
389+
cli.StringFlag{
390+
Name: "serviceaccount, sa",
391+
Usage: "Value is filename and path of credentials.json which was retrieved by creating Service Account.",
392+
},
393+
},
394+
},
395+
{
396+
Name: "permissions",
397+
Aliases: []string{"p"},
398+
Usage: "Manage file permissions.",
399+
Description: "In this mode, an access token is required.",
400+
Action: managePermissions,
401+
Flags: []cli.Flag{
402+
cli.StringFlag{
403+
Name: "fileid, fi",
404+
Usage: "Value is file ID. This value is required.",
405+
},
406+
cli.StringFlag{
407+
Name: "permissionid, pi",
408+
Usage: "Value is permission ID. This ID can be retrieved by retrieving permission list.",
409+
},
410+
cli.BoolFlag{
411+
Name: "create, c",
412+
Usage: "Create new permissions.",
413+
},
414+
cli.BoolFlag{
415+
Name: "delete, d",
416+
Usage: "Delete permissions. fileId and permissionId are required.",
417+
},
418+
cli.StringFlag{
419+
Name: "role",
420+
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",
421+
},
422+
cli.StringFlag{
423+
Name: "type",
424+
Usage: "The type of the grantee. Valid values are: user, group, domain, anyone",
425+
},
426+
cli.StringFlag{
427+
Name: "emailaddress, email",
428+
Usage: "The email address of the user or group to which this permission refers.",
429+
},
430+
cli.BoolFlag{
431+
Name: "transferownership, transfer",
432+
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)",
433+
},
434+
cli.BoolFlag{
435+
Name: "jsonparser, j",
436+
Usage: "Display results by JSON parser",
437+
},
438+
cli.StringFlag{
439+
Name: "serviceaccount, sa",
440+
Usage: "Value is filename and path of credentials.json which was retrieved by creating Service Account.",
441+
},
442+
},
443+
},
444+
{
445+
Name: "driveinformation",
446+
Aliases: []string{"di"},
447+
Usage: "Get drive information.",
448+
Description: "In this mode, an access token is required.",
449+
Action: getDriveInformation,
450+
Flags: []cli.Flag{
451+
cli.StringFlag{
452+
Name: "fields, f",
453+
Usage: "Fields for retrieving files.",
454+
Value: "storageQuota,user",
455+
},
456+
cli.BoolFlag{
457+
Name: "jsonparser, j",
458+
Usage: "Display results by JSON parser",
459+
},
460+
cli.StringFlag{
461+
Name: "serviceaccount, sa",
462+
Usage: "Value is filename and path of credentials.json which was retrieved by creating Service Account.",
463+
},
369464
},
370465
},
371466
{

handler.go

+22
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,28 @@ func searchFilesByQueryAndRegex(c *cli.Context) error {
113113
return nil
114114
}
115115

116+
// managePermissions : Manage permissions.
117+
func managePermissions(c *cli.Context) error {
118+
res := defAuthContainer(c).
119+
ggsrunIni(c).
120+
goauth().
121+
defPermissionsContainer(c).
122+
ManagePermissions()
123+
dispTransferResult(c, res)
124+
return nil
125+
}
126+
127+
// getDriveInformation : Get drive information.
128+
func getDriveInformation(c *cli.Context) error {
129+
res := defAuthContainer(c).
130+
ggsrunIni(c).
131+
goauth().
132+
defDownloadContainer(c).
133+
GetDriveInformation()
134+
dispTransferResult(c, res)
135+
return nil
136+
}
137+
116138
// reAuth : Retrieve tokens again.
117139
func reAuth(c *cli.Context) error {
118140
defAuthContainer(c).

0 commit comments

Comments
 (0)