rmdir.go 1014 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Package rmdir provides the rmdir command.
  2. package rmdir
  3. import (
  4. "context"
  5. "github.com/rclone/rclone/cmd"
  6. "github.com/rclone/rclone/fs/operations"
  7. "github.com/spf13/cobra"
  8. )
  9. func init() {
  10. cmd.Root.AddCommand(commandDefinition)
  11. }
  12. var commandDefinition = &cobra.Command{
  13. Use: "rmdir remote:path",
  14. Short: `Remove the empty directory at path.`,
  15. Long: `
  16. This removes empty directory given by path. Will not remove the path if it
  17. has any objects in it, not even empty subdirectories. Use
  18. command [rmdirs](/commands/rclone_rmdirs/) (or [delete](/commands/rclone_delete/)
  19. with option ` + "`--rmdirs`" + `) to do that.
  20. To delete a path and any objects in it, use [purge](/commands/rclone_purge/) command.
  21. `,
  22. Annotations: map[string]string{
  23. "groups": "Important",
  24. },
  25. Run: func(command *cobra.Command, args []string) {
  26. cmd.CheckArgs(1, 1, command, args)
  27. fdst := cmd.NewFsDir(args)
  28. cmd.Run(true, false, command, func() error {
  29. return operations.Rmdir(context.Background(), fdst, "")
  30. })
  31. },
  32. }