databricks-cli/cmd/fs/rm.go

38 lines
822 B
Go
Raw Permalink Normal View History

2023-06-05 01:07:19 +00:00
package fs
import (
"github.com/databricks/cli/cmd/root"
"github.com/databricks/databricks-sdk-go/service/files"
"github.com/spf13/cobra"
)
var rmCmd = &cobra.Command{
2023-06-05 15:48:21 +00:00
Use: "rm PATH",
2023-06-05 01:07:19 +00:00
Short: "Remove files and directories from dbfs.",
Long: `Remove files and directories from dbfs.`,
Args: cobra.ExactArgs(1),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
2023-06-05 13:42:56 +00:00
path, err := resolveDbfsPath(args[0])
2023-06-05 01:07:19 +00:00
if err != nil {
return err
}
return w.Dbfs.Delete(ctx, files.Delete{
Path: path,
Recursive: recursive,
})
},
}
var recursive bool
func init() {
2023-06-05 15:48:21 +00:00
rmCmd.Flags().BoolVarP(&recursive, "recursive", "r", false, "Recursively delete a non-empty directory.")
2023-06-05 01:07:19 +00:00
fsCmd.AddCommand(rmCmd)
}