@@ -184,6 +184,23 @@ func (myApp MyApp) syncAction(cCtx *cli.Context, src, dst string, up bool) error
184184 return nil
185185}
186186
187+ func (myApp MyApp ) copyMoveAction (
188+ cCtx * cli.Context ,
189+ action func (context.Context , string , string ) (client.FileManagerResponse , error ),
190+ ) error {
191+ remotepath0 := cCtx .Args ().Get (0 )
192+ remotepath1 := cCtx .Args ().Get (1 )
193+ if remotepath0 == "" || remotepath1 == "" {
194+ return cli .Exit ("remotepath0 and remotepath1 arguments are required" , 1 )
195+ }
196+ resp , err := action (myApp .ctx , remotepath0 , remotepath1 )
197+ if err != nil {
198+ return cli .Exit (err , 1 )
199+ }
200+ myApp .render .Render (resp )
201+ return nil
202+ }
203+
187204func (myApp MyApp ) Run (args []string ) {
188205 cfg := config .Global
189206
@@ -417,6 +434,39 @@ func (myApp MyApp) Run(args []string) {
417434 return myApp .syncAction (cCtx , src , dst , false )
418435 },
419436 },
437+ {
438+ Name : "rename" ,
439+ ArgsUsage : "remotepath newname" ,
440+ Action : func (cCtx * cli.Context ) error {
441+ path := cCtx .Args ().Get (0 )
442+ newname := cCtx .Args ().Get (1 )
443+ if path == "" || newname == "" {
444+ return cli .Exit ("path and newname arguments are required" , 1 )
445+ }
446+ resp , err := myApp .dstClient .Rename (myApp .ctx , path , newname )
447+ if err != nil {
448+ return cli .Exit (err , 1 )
449+ }
450+ myApp .render .Render (resp )
451+ return nil
452+ },
453+ },
454+ {
455+ Name : "mv" ,
456+ Aliases : []string {"move" },
457+ ArgsUsage : "remotepath0 remotepath1" ,
458+ Action : func (cCtx * cli.Context ) error {
459+ return myApp .copyMoveAction (cCtx , myApp .dstClient .Move )
460+ },
461+ },
462+ {
463+ Name : "cp" ,
464+ Aliases : []string {"copy" },
465+ ArgsUsage : "remotepath0 remotepath1" ,
466+ Action : func (cCtx * cli.Context ) error {
467+ return myApp .copyMoveAction (cCtx , myApp .dstClient .Copy )
468+ },
469+ },
420470 },
421471 Authors : []* cli.Author {
422472 & cli.Author {Name : "Yousong Zhou" , Email : "yszhou4tech@gmail.com" },
0 commit comments