2016-08-05 16:12:27 +00:00
|
|
|
package rmdir
|
|
|
|
|
|
|
|
import (
|
2019-06-17 08:34:30 +00:00
|
|
|
"context"
|
|
|
|
|
2019-07-28 17:47:38 +00:00
|
|
|
"github.com/rclone/rclone/cmd"
|
|
|
|
"github.com/rclone/rclone/fs/operations"
|
2016-08-05 16:12:27 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2019-10-11 15:58:11 +00:00
|
|
|
cmd.Root.AddCommand(commandDefinition)
|
2016-08-05 16:12:27 +00:00
|
|
|
}
|
|
|
|
|
2019-10-11 15:58:11 +00:00
|
|
|
var commandDefinition = &cobra.Command{
|
2016-08-05 16:12:27 +00:00
|
|
|
Use: "rmdir remote:path",
|
|
|
|
Short: `Remove the path if empty.`,
|
|
|
|
Long: `
|
|
|
|
Remove the path. Note that you can't remove a path with
|
|
|
|
objects in it, use purge for that.`,
|
|
|
|
Run: func(command *cobra.Command, args []string) {
|
|
|
|
cmd.CheckArgs(1, 1, command, args)
|
2018-05-07 16:58:16 +00:00
|
|
|
fdst := cmd.NewFsDir(args)
|
2016-12-04 16:52:24 +00:00
|
|
|
cmd.Run(true, false, command, func() error {
|
2019-06-17 08:34:30 +00:00
|
|
|
return operations.Rmdir(context.Background(), fdst, "")
|
2016-08-05 16:12:27 +00:00
|
|
|
})
|
|
|
|
},
|
|
|
|
}
|