@@ -196,29 +196,55 @@ func volumesRemoveCommand(cmdr *commands.DryccCmd) *cobra.Command {
196196}
197197
198198func volumesClientCommand (cmdr * commands.DryccCmd ) * cobra.Command {
199- volumesCmdCompletion := completion.VolumesCmdCompletion {ArgsLen : 0 , ConfigFile : & cmdr .ConfigFile }
200199 cmd := & cobra.Command {
201- Use : "client <cmd> <args>..." ,
200+ Use : "client" ,
201+ Short : i18n .T ("The client used to manage volume files" ),
202+ }
203+ cmd .AddCommand (& cobra.Command {
204+ Use : "ls <target>" ,
202205 Example : template .CustomExample (
203- "drycc volumes client ls vol://myvolume/" ,
206+ "drycc volumes client ls vol://myvolume/tmp " ,
204207 map [string ]string {
205- "<cmd>" : i18n .T (`ls list volume files
206- cp copy volume files
207- rm remove volume files` ),
208- "<args>" : i18n .T (`arguments for running commands, when cmd is 'cp', args should be '[source] [dest]'.
209- volume path format 'vol://volumename/', '/' is equivalent to the mount path.` ),
208+ "<target>" : i18n .T ("The target path of volume" ),
210209 },
211210 ),
211+ Short : i18n .T ("List volume objects" ),
212+ Args : cobra .ExactArgs (1 ),
213+ RunE : func (_ * cobra.Command , args []string ) error {
214+ return cmdr .VolumesClient (app , "ls" , args ... )
215+ },
216+ })
212217
213- Short : i18n .T ("The client used to manage volume files" ),
214- Args : cobra .MinimumNArgs (2 ),
215- ValidArgsFunction : volumesCmdCompletion .CompletionFunc ,
218+ cmd .AddCommand (& cobra.Command {
219+ Use : "cp <source> <target>" ,
220+ Example : template .CustomExample (
221+ "drycc volumes client cp vol://myvolume/tmp /tmp" ,
222+ map [string ]string {
223+ "<source>" : i18n .T ("The volume or local source path" ),
224+ "<target>" : i18n .T ("The volume or local target path" ),
225+ },
226+ ),
227+ Short : i18n .T ("Copy volume objects" ),
228+ Args : cobra .ExactArgs (2 ),
216229 RunE : func (_ * cobra.Command , args []string ) error {
217- cmdType := args [0 ]
218- cmdArgs := args [1 :]
219- return cmdr .VolumesClient (app , cmdType , cmdArgs ... )
230+ return cmdr .VolumesClient (app , "cp" , args ... )
220231 },
221- }
232+ })
233+
234+ cmd .AddCommand (& cobra.Command {
235+ Use : "rm <target>" ,
236+ Example : template .CustomExample (
237+ "drycc volumes client rm vol://myvolume/tmp" ,
238+ map [string ]string {
239+ "<target>" : i18n .T ("The target path of volume" ),
240+ },
241+ ),
242+ Short : i18n .T ("Remove volume objects" ),
243+ Args : cobra .ExactArgs (1 ),
244+ RunE : func (_ * cobra.Command , args []string ) error {
245+ return cmdr .VolumesClient (app , "rm" , args ... )
246+ },
247+ })
222248
223249 return cmd
224250}
0 commit comments