Skip to content

Commit

Permalink
feature:上传增加--save-uploaded-file --suf参数,用于指定上传信息保存文件路径
Browse files Browse the repository at this point in the history
  • Loading branch information
qinxiandiqi committed May 19, 2023
1 parent 1d6b6da commit df0bdbd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions api/rio_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type FirApi struct {
QrCodePngNeed bool
QrCodeAsciiNeed bool
SaveUploadedInfo bool
SaveUploadedPath string
ApiAppInfo *ApiAppInfo
uploadAppService *analysis.UploadAppService
appFileInfo *analysis.AppFileInfo
Expand Down
14 changes: 12 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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)
Expand All @@ -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") != "" {
Expand Down
4 changes: 2 additions & 2 deletions utils/save_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}

0 comments on commit df0bdbd

Please sign in to comment.