-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
168 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.0.0" | ||
app.Version = "1.1.0" | ||
app.Commands = []cli.Command{ | ||
{ | ||
Name: "exe1", | ||
|
@@ -198,6 +198,31 @@ func main() { | |
}, | ||
}, | ||
}, | ||
{ | ||
Name: "updateproject", | ||
Aliases: []string{"ud"}, | ||
Usage: "Updates project on Google Drive.", | ||
Description: "In this mode, an access token is required.", | ||
Action: updateProject, | ||
Flags: []cli.Flag{ | ||
cli.StringFlag{ | ||
Name: "filename, f", | ||
Usage: "File name. It's source files for updating.", | ||
}, | ||
cli.StringFlag{ | ||
Name: "projectid, p", | ||
Usage: "ID of existing project. It's a destination project for updating.", | ||
}, | ||
cli.BoolFlag{ | ||
Name: "backup, b", | ||
Usage: "Backup project with project ID you set as a file.", | ||
}, | ||
cli.BoolFlag{ | ||
Name: "jsonparser, j", | ||
Usage: "Display results by JSON parser", | ||
}, | ||
}, | ||
}, | ||
{ | ||
Name: "filelist", | ||
Aliases: []string{"ls"}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Package main (projectupdater.go) : | ||
// These methods are for updating project. | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
|
||
"github.com/tanaikech/ggsrun/utl" | ||
"github.com/urfave/cli" | ||
) | ||
|
||
// projectUpdateControl : Main method for updating project. | ||
func (e *ExecutionContainer) projectUpdateControl(c *cli.Context) *utl.FileInf { | ||
if len(c.String("filename")) == 0 { | ||
fmt.Fprintf(os.Stderr, "Error: No Files. Please set them using '-f [ File name ]'. ") | ||
os.Exit(1) | ||
} | ||
if len(c.String("projectid")) > 0 { | ||
e.GgsrunCfg.Scriptid = c.String("projectid") | ||
} | ||
return e.defUpdateProjectContainer(c). | ||
projectBackup(c). | ||
ProjectMaker(). | ||
projectUpdate(). | ||
dispUpdateProjectContainer() | ||
} | ||
|
||
// ProjectMaker : Recreates the project using uploaded scripts. | ||
func (e *ExecutionContainer) ProjectMaker() *ExecutionContainer { | ||
for _, elm := range e.UpFiles { | ||
if filepath.Ext(elm) == ".gs" || | ||
filepath.Ext(elm) == ".gas" || | ||
filepath.Ext(elm) == ".js" || | ||
filepath.Ext(elm) == ".htm" || | ||
filepath.Ext(elm) == ".html" { | ||
filedata := &File{ | ||
Name: strings.Replace(filepath.Base(elm), filepath.Ext(elm), "", -1), | ||
Type: func(ex string) string { | ||
var scripttype string | ||
switch ex { | ||
case ".gs", ".gas", ".js": | ||
scripttype = "server_js" | ||
case ".htm", ".html": | ||
scripttype = "html" | ||
} | ||
return scripttype | ||
}(filepath.Ext(elm)), | ||
Source: utl.ConvGasToUpload(elm), | ||
} | ||
var overwrite bool | ||
for i, v := range e.Project.Files { | ||
if v.Name == filedata.Name { | ||
e.Project.Files[i].Source = filedata.Source | ||
e.Msg = append(e.Msg, fmt.Sprintf("Script '%s' in project was overwritten.", v.Name)) | ||
overwrite = true | ||
} | ||
} | ||
if !overwrite { | ||
e.Project.Files = append(e.Project.Files, *filedata) | ||
} | ||
} | ||
} | ||
e.Msg = append(e.Msg, fmt.Sprintf("Project ID '%s' was uploaded.", e.Scriptid)) | ||
return e | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters