github.com/xhghs/rclone@v1.51.1-0.20200430155106-e186a28cced8/cmd/cleanup/cleanup.go (about) 1 package cleanup 2 3 import ( 4 "context" 5 6 "github.com/rclone/rclone/cmd" 7 "github.com/rclone/rclone/fs/operations" 8 "github.com/spf13/cobra" 9 ) 10 11 func init() { 12 cmd.Root.AddCommand(commandDefinition) 13 } 14 15 var commandDefinition = &cobra.Command{ 16 Use: "cleanup remote:path", 17 Short: `Clean up the remote if possible`, 18 Long: ` 19 Clean up the remote if possible. Empty the trash or delete old file 20 versions. Not supported by all remotes. 21 `, 22 Run: func(command *cobra.Command, args []string) { 23 cmd.CheckArgs(1, 1, command, args) 24 fsrc := cmd.NewFsSrc(args) 25 cmd.Run(true, false, command, func() error { 26 return operations.CleanUp(context.Background(), fsrc) 27 }) 28 }, 29 }