diff --git a/api/rio_api.go b/api/rio_api.go index 50dcfbe..37bda9f 100644 --- a/api/rio_api.go +++ b/api/rio_api.go @@ -30,6 +30,7 @@ type FirApi struct { QrCodePngNeed bool QrCodeAsciiNeed bool SaveUploadedInfo bool + SaveUploadedPath string ApiAppInfo *ApiAppInfo uploadAppService *analysis.UploadAppService appFileInfo *analysis.AppFileInfo diff --git a/main.go b/main.go index ed556fa..479d664 100644 --- a/main.go +++ b/main.go @@ -159,7 +159,12 @@ func uploadFile() cli.Command { cli.BoolFlag{ Name: "save-uploaded-info, sui", - Usage: "上传成功后, 保存上传信息到本地 go-fir-cli-answer.json, 用于用户的其他集成操作, 默认为 false", + Usage: "上传成功后, 保存上传信息到本地json文件(默认为go-fir-cli-answer.json), 用于用户的其他集成操作, 默认为 false", + }, + + cli.StringFlag{ + Name: "save-uploaded-file, suf", + Usage: "指定上传成功后, 保存的上传文件路径,默认为当前目录的go-fir-cli-answer.json", }, cli.StringFlag{ @@ -242,6 +247,7 @@ func uploadFile() cli.Command { QrCodePngNeed: c.Bool("qrcode"), QrCodeAsciiNeed: c.Bool("qrcodeascii"), SaveUploadedInfo: c.Bool("save-uploaded-info"), + SaveUploadedPath: c.String("save-uploaded-file"), } api.Upload(file) @@ -256,7 +262,11 @@ func uploadFile() cli.Command { } if api.SaveUploadedInfo { - utils.SaveAnswer(api.ApiAppInfo) + if api.SaveUploadedPath != "" { + utils.SaveAnswer(api.SaveUploadedPath, api.ApiAppInfo) + } else { + utils.SaveAnswer("go-fir-cli-answer.json", api.ApiAppInfo) + } } if c.String("dingtalkToken") != "" { diff --git a/utils/save_file.go b/utils/save_file.go index a29f909..6d9b2a5 100644 --- a/utils/save_file.go +++ b/utils/save_file.go @@ -8,7 +8,7 @@ import ( "github.com/PGYER/go-fir-cli/api" ) -func SaveAnswer(apiAppInfo *api.ApiAppInfo) error { +func SaveAnswer(filePath string, apiAppInfo *api.ApiAppInfo) error { // fileName := "fir-cli-answer.json" data := make(map[string]string) @@ -23,7 +23,7 @@ func SaveAnswer(apiAppInfo *api.ApiAppInfo) error { json, _ := json.Marshal(data) // 将 data 转化为 json 后存储到本地answer.json 中 - ioutil.WriteFile("go-fir-cli-answer.json", json, 0644) + ioutil.WriteFile(filePath, json, 0644) return nil }