Skip to content

Commit 67a7c93

Browse files
authored
Merge pull request #379 from YangSen-qn/cmd-style
Cmd style
2 parents bac240d + be771f2 commit 67a7c93

40 files changed

+398
-185
lines changed

cmd/asyncfetch.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ func asyncFetchCmdBuilder(cfg *iqshell.Config) *cobra.Command {
3131
cmd.Flags().StringVarP(&info.CallbackUrl, "callback-url", "a", "", "callback url")
3232
cmd.Flags().StringVarP(&info.CallbackBody, "callback-body", "b", "", "callback body")
3333
cmd.Flags().StringVarP(&info.CallbackHost, "callback-host", "T", "", "callback HOST")
34-
cmd.Flags().IntVarP(&info.FileType, "storage-type", "g", 0, "storage type")
35-
cmd.Flags().BoolVar(&info.Overwrite, "overwrite", false, "overwrite the file of same key in bucket")
34+
35+
cmd.Flags().IntVarP(&info.FileType, "file-type", "", 0, "storage type, 0:STANDARD storage, 1:IA storage, 2:ARCHIVE storage, 3:DEEP_ARCHIVE storage")
36+
cmd.Flags().IntVarP(&info.FileType, "storage-type", "g", 0, "storage type, same to --file-type")
37+
_ = cmd.Flags().MarkDeprecated("storage-type", "use --file-type instead") // 废弃 storage-type
38+
39+
cmd.Flags().BoolVarP(&info.Overwrite, "overwrite", "", false, "overwrite the file of same key in bucket")
3640
cmd.Flags().StringVarP(&info.BatchInfo.InputFile, "input-file", "i", "", "input file with urls")
3741
cmd.Flags().IntVarP(&info.BatchInfo.WorkerCount, "thread-count", "c", 20, "thread count")
3842
cmd.Flags().BoolVarP(&info.BatchInfo.EnableRecord, "enable-record", "", false, "record work progress, and do from last progress while retry")

cmd/aws.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ func awsFetchCmdBuilder(cfg *iqshell.Config) *cobra.Command {
3333
cmd.Flags().Int64VarP(&info.AwsBucketInfo.MaxKeys, "max-keys", "n", 1000, "list AWS bucket with numbers of keys returned each time limited by this number if set")
3434
cmd.Flags().StringVarP(&info.AwsBucketInfo.CToken, "continuation-token", "m", "", "AWS list continuation token")
3535
cmd.Flags().IntVarP(&info.BatchInfo.WorkerCount, "thread-count", "c", 20, "maximum of fetch thread")
36-
cmd.Flags().StringVarP(&info.Host, "up-host", "u", "", "Qiniu fetch up host")
36+
37+
// 没有实际作用
38+
cmd.Flags().StringVarP(&info.Host, "up-host", "u", "", "Qiniu fetch up host, deprecated")
39+
_ = cmd.Flags().MarkDeprecated("up-host", "deprecated")
40+
3741
cmd.Flags().StringVarP(&info.AwsBucketInfo.SecretKey, "aws-secret-key", "S", "", "AWS secret key")
3842
cmd.Flags().StringVarP(&info.AwsBucketInfo.Id, "aws-id", "A", "", "AWS ID")
3943
cmd.Flags().StringVarP(&info.BatchInfo.SuccessExportFilePath, "success-list", "s", "", "success fetch key list")

cmd/bucket.go

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ var listBucketCmd2Builder = func(cfg *iqshell.Config) *cobra.Command {
9595
var cmd = &cobra.Command{
9696
Use: "listbucket2 <Bucket>",
9797
Short: "List all the files in the bucket using v2/list interface",
98-
Long: "List all the files in the bucket using v2/list interface to stdout if output file not specified. Each row of data information is displayed in the following order by default:\n Key\tFileSize\tHash\tPutTime\tMimeType\tStorageType\tEndUser",
98+
Long: "List all the files in the bucket using v2/list interface to stdout if output file not specified. Each row of data information is displayed in the following order by default:\n Key\tFileSize\tHash\tPutTime\tMimeType\tFileType\tEndUser",
9999
Run: func(cmd *cobra.Command, args []string) {
100100
cfg.CmdCfg.CmdId = docs.ListBucket2Type
101101
if len(args) > 0 {
@@ -107,19 +107,26 @@ var listBucketCmd2Builder = func(cfg *iqshell.Config) *cobra.Command {
107107

108108
cmd.Flags().StringVarP(&info.Marker, "marker", "m", "", "list marker")
109109
cmd.Flags().StringVarP(&info.Prefix, "prefix", "p", "", "list by prefix")
110-
cmd.Flags().StringVarP(&info.Suffixes, "suffixes", "q", "", "list by key suffixes, separated by comma")
110+
cmd.Flags().StringVarP(&info.Suffixes, "suffixes", "q", "", "list by key suffixes, separated by comma, all files will be listed according to the prefix and then filtered.")
111111
cmd.Flags().IntVarP(&info.MaxRetry, "max-retry", "x", -1, "max retries when error occurred")
112-
cmd.Flags().StringVarP(&info.SaveToFile, "out", "o", "", "output file")
112+
113+
cmd.Flags().StringVarP(&info.SaveToFile, "out", "", "", "output file")
114+
cmd.Flags().StringVarP(&info.SaveToFile, "outfile", "o", "", "output file")
115+
_ = cmd.Flags().MarkDeprecated("out", "use --outfile instead")
116+
113117
cmd.Flags().IntVarP(&info.OutputLimit, "limit", "", -1, "max count of items to output")
114-
cmd.Flags().Int64VarP(&info.OutputFileMaxLines, "output-file-max-lines", "", 0, "maximum number of lines per output file.")
115-
cmd.Flags().Int64VarP(&info.OutputFileMaxSize, "output-file-max-size", "", 0, "maximum size of each output file")
116-
cmd.Flags().StringVarP(&info.StartDate, "start", "s", "", "start date with format yyyy-mm-dd-hh-MM-ss")
117-
cmd.Flags().StringVarP(&info.EndDate, "end", "e", "", "end date with format yyyy-mm-dd-hh-MM-ss")
118+
cmd.Flags().Int64VarP(&info.OutputFileMaxLines, "output-file-max-lines", "", 0, "maximum number of lines per output file, a new export file will be created when the limit is exceeded.")
119+
cmd.Flags().Int64VarP(&info.OutputFileMaxSize, "output-file-max-size", "", 0, "maximum size of each output file, a new export file will be created when the limit is exceeded.")
120+
cmd.Flags().StringVarP(&info.StartDate, "start", "s", "", "start date with format yyyy-mm-dd-hh-MM-ss, all files will be listed according to the prefix and then filtered.")
121+
cmd.Flags().StringVarP(&info.EndDate, "end", "e", "", "end date with format yyyy-mm-dd-hh-MM-ss, all files will be listed according to the prefix and then filtered.")
122+
123+
cmd.Flags().StringVarP(&info.FileTypes, "file-types", "", "", "Specify storage type, separated by comma, all files will be listed according to the prefix and then filtered. 0:STANDARD storage, 1:IA storage, 2 means ARCHIVE storage. 3:DEEP_ARCHIVE storage")
124+
cmd.Flags().StringVarP(&info.FileTypes, "storages", "", "", "Specify storage type, same to --file-types")
125+
_ = cmd.Flags().MarkDeprecated("storages", "use --file-types instead") // 废弃 storages
118126

119-
cmd.Flags().StringVarP(&info.StorageTypes, "storages", "", "", "Specify storage type, separated by comma. 0:STANDARD storage, 1:IA storage, 2 means ARCHIVE storage. 3:DEEP_ARCHIVE storage")
120-
cmd.Flags().StringVarP(&info.MimeTypes, "mimetypes", "", "", "Specify mimetype, separated by comma.")
121-
cmd.Flags().StringVarP(&info.MinFileSize, "min-file-size", "", "", "Specify min file size")
122-
cmd.Flags().StringVarP(&info.MaxFileSize, "max-file-size", "", "", "Specify max file size")
127+
cmd.Flags().StringVarP(&info.MimeTypes, "mimetypes", "", "", "Specify mimetype, separated by comma, all files will be listed according to the prefix and then filtered.")
128+
cmd.Flags().StringVarP(&info.MinFileSize, "min-file-size", "", "", "Specify min file size, all files will be listed according to the prefix and then filtered.")
129+
cmd.Flags().StringVarP(&info.MaxFileSize, "max-file-size", "", "", "Specify max file size, all files will be listed according to the prefix and then filtered.")
123130

124131
cmd.Flags().BoolVarP(&info.AppendMode, "append", "a", false, "result append to file instead of overwriting")
125132
cmd.Flags().BoolVarP(&info.Readable, "readable", "r", false, "present file size with human readable format")
@@ -128,7 +135,7 @@ var listBucketCmd2Builder = func(cfg *iqshell.Config) *cobra.Command {
128135
cmd.Flags().BoolVarP(&info.EnableRecord, "enable-record", "", false, "record the execution status of the listbucket2 command. When the listbucket2 command is executed next time, the marker will be automatically filled and the listbucket2 will continue. Enabling this option will automatically enable append (see the --append option for details). The id of the record is related to the bucket where the file is located, the prefix listed, and the path where the file is saved.")
129136

130137
cmd.Flags().StringVarP(&info.OutputFieldsSep, "output-fields-sep", "", data.DefaultLineSeparate, "Each line needs to display the delimiter of the file information.")
131-
cmd.Flags().StringVarP(&info.ShowFields, "show-fields", "", "", "The file attributes to be displayed on each line, separated by commas. Optional range: Key, Hash, FileSize, PutTime, MimeType, StorageType, EndUser.")
138+
cmd.Flags().StringVarP(&info.ShowFields, "show-fields", "", "", "The file attributes to be displayed on each line, separated by commas. Optional range: Key, Hash, FileSize, PutTime, MimeType, FileType, EndUser.")
132139

133140
return cmd
134141
}

cmd/download.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ have already in local disk and need to skip download or not.`,
2929
},
3030
}
3131
cmd.Flags().StringVarP(&info.SuccessExportFilePath, "success-list", "s", "", "specifies the file path where the successful file list is saved")
32-
cmd.Flags().StringVarP(&info.FailExportFilePath, "failure-list", "f", "", "specifies the file path where the failure file list is saved")
32+
cmd.Flags().StringVarP(&info.FailExportFilePath, "failure-list", "e", "", "specifies the file path where the failure file list is saved")
33+
34+
cmd.Flags().IntVarP(&info.WorkerCount, "thread-count", "c", 5, "num of threads to download files")
35+
cmd.Flags().IntVarP(&info.WorkerCount, "thread", "", 5, "num of threads to download files")
36+
_ = cmd.Flags().MarkDeprecated("thread", "use --thread-count instead") // 废弃 thread-count
3337

34-
cmd.Flags().IntVarP(&info.WorkerCount, "thread", "c", 5, "num of threads to download files")
3538
return cmd
3639
}
3740

@@ -62,9 +65,12 @@ have already in local disk and need to skip download or not.`,
6265
},
6366
}
6467
cmd.Flags().StringVarP(&info.SuccessExportFilePath, "success-list", "s", "", "specifies the file path where the successful file list is saved")
65-
cmd.Flags().StringVarP(&info.FailExportFilePath, "failure-list", "f", "", "specifies the file path where the failure file list is saved")
68+
cmd.Flags().StringVarP(&info.FailExportFilePath, "failure-list", "e", "", "specifies the file path where the failure file list is saved")
69+
70+
cmd.Flags().IntVarP(&info.WorkerCount, "thread-count", "c", 5, "num of threads to download files")
71+
cmd.Flags().IntVarP(&info.WorkerCount, "thread", "", 5, "num of threads to download files")
72+
_ = cmd.Flags().MarkDeprecated("thread", "use --thread-count instead") // 废弃 thread-count
6673

67-
cmd.Flags().IntVarP(&info.WorkerCount, "thread", "c", 5, "num of threads to download files")
6874
cmd.Flags().StringVarP(&info.DownloadCfg.DestDir, "dest-dir", "", "", "local storage path, full path. default current dir")
6975
cmd.Flags().BoolVarP(&info.DownloadCfg.GetFileApi, "get-file-api", "", false, "public storage cloud not support, private storage cloud support when has getfile api.")
7076
cmd.Flags().StringVarP(&info.DownloadCfg.Bucket, "bucket", "", "", "storage bucket")
@@ -75,7 +81,11 @@ have already in local disk and need to skip download or not.`,
7581
cmd.Flags().BoolVarP(&info.DownloadCfg.CheckHash, "check-hash", "", false, "whether to verify the hash, if it is enabled, it may take a long time")
7682
cmd.Flags().BoolVarP(&info.DownloadCfg.CheckSize, "check-size", "", false, "check the consistency of the file size between the local file and the server file. the download fails while the file is inconsistent.")
7783
cmd.Flags().StringVarP(&info.IoHost, "io-host", "", "", "io host of request")
78-
cmd.Flags().StringVarP(&info.DownloadCfg.CdnDomain, "cdn-domain", "", "", "set the CDN domain name for downloading, the default is empty, which means downloading from the storage source site")
84+
85+
cmd.Flags().StringVarP(&info.DownloadCfg.Domain, "cdn-domain", "", "", "same to --domain, deprecated")
86+
cmd.Flags().StringVarP(&info.DownloadCfg.Domain, "domain", "", "", "domain of the download request, the default is empty, which means downloading from the storage source site")
87+
_ = cmd.Flags().MarkDeprecated("cdn-domain", "use --domain instead")
88+
7989
cmd.Flags().StringVarP(&info.DownloadCfg.Referer, "referer", "", "", "if the CDN domain name is configured with domain name whitelist anti-leech, you need to specify a referer address that allows access")
8090
cmd.Flags().BoolVarP(&info.DownloadCfg.Public, "public", "", false, "whether the space is a public space")
8191
cmd.Flags().BoolVarP(&info.DownloadCfg.EnableSlice, "enable-slice", "", false, "whether to enable slice download, you need to pay attention to the configuration of --slice-file-size-threshold slice threshold option. Only when slice download is enabled and the size of the downloaded file is greater than the slice threshold will the slice download be started")
@@ -110,7 +120,7 @@ var getCmdBuilder = func(cfg *iqshell.Config) *cobra.Command {
110120
}
111121

112122
cmd.Flags().StringVarP(&info.ToFile, "outfile", "o", "", "save file as specified by this option")
113-
cmd.Flags().StringVarP(&info.Domain, "domain", "", "", "domain of request")
123+
cmd.Flags().StringVarP(&info.Domain, "domain", "", "", "domain of the download request")
114124
cmd.Flags().BoolVarP(&info.CheckHash, "check-hash", "", false, "check the consistency of the hash between the local file and the server file. the download fails while the file is inconsistent.")
115125
cmd.Flags().BoolVarP(&info.CheckSize, "check-size", "", false, "check the consistency of the file size between the local file and the server file. the download fails while the file is inconsistent.")
116126
cmd.Flags().BoolVarP(&info.UseGetFileApi, "get-file-api", "", false, "public storage cloud not support, private storage cloud support when has getfile api.")

cmd/fop.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ var preFopCmdBuilder = func(cfg *iqshell.Config) *cobra.Command {
4747
}
4848
cmd.Flags().StringVarP(&info.Pipeline, "pipeline", "p", "", "task pipeline")
4949
cmd.Flags().StringVarP(&info.NotifyURL, "notify-url", "u", "", "notfiy url")
50-
cmd.Flags().BoolVarP(&info.NotifyForce, "force", "f", false, "force execute")
50+
51+
cmd.Flags().BoolVarP(&info.NotifyForce, "force", "y", false, "force execute")
52+
cmd.Flags().BoolVarP(&info.NotifyForce, "force-old", "f", false, "force execute, deprecated")
53+
_ = cmd.Flags().MarkDeprecated("force-old", "use --force instead")
54+
5155
return cmd
5256
}
5357

cmd/rs.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ var moveCmdBuilder = func(cfg *iqshell.Config) *cobra.Command {
111111
},
112112
}
113113
cmd.Flags().BoolVarP(&info.Force, "overwrite", "w", false, "overwrite mode")
114+
_ = cmd.Flags().MarkShorthandDeprecated("overwrite", "deprecated and use --overwrite instead")
115+
114116
cmd.Flags().StringVarP(&info.DestKey, "key", "k", "", "filename saved in bucket")
115117
return cmd
116118
}
@@ -141,6 +143,8 @@ you can check if B.png has exists by:
141143
},
142144
}
143145
cmd.Flags().BoolVarP(&info.Force, "overwrite", "w", false, "overwrite mode")
146+
_ = cmd.Flags().MarkShorthandDeprecated("overwrite", "deprecated and use --overwrite instead")
147+
144148
return cmd
145149
}
146150

@@ -169,6 +173,8 @@ you can check if B.png has exists by:
169173
},
170174
}
171175
cmd.Flags().BoolVarP(&info.Force, "overwrite", "w", false, "overwrite mode")
176+
_ = cmd.Flags().MarkShorthandDeprecated("overwrite", "deprecated and use --overwrite instead")
177+
172178
cmd.Flags().StringVarP(&info.DestKey, "key", "k", "", "filename saved in bucket, use <SrcKey> while omitted")
173179
return cmd
174180
}

cmd/rsbatch.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ func setBatchCmdFailExportFileFlags(cmd *cobra.Command, info *batch.Info) {
311311
}
312312
func setBatchCmdOverwriteFlags(cmd *cobra.Command, info *batch.Info) {
313313
cmd.Flags().BoolVarP(&info.Overwrite, "overwrite", "w", false, "overwrite mode")
314+
_ = cmd.Flags().MarkShorthandDeprecated("overwrite", "deprecated and use --overwrite instead")
314315
}
315316

316317
func init() {

0 commit comments

Comments
 (0)