2023-06-12 12:05:56 +00:00
|
|
|
package fs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/databricks/cli/cmd/root"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2023-07-27 10:03:08 +00:00
|
|
|
func newMkdirCommand() *cobra.Command {
|
|
|
|
cmd := &cobra.Command{
|
|
|
|
Use: "mkdir DIR_PATH",
|
|
|
|
// Alias `mkdirs` for this command exists for legacy purposes. This command
|
|
|
|
// is called databricks fs mkdirs in our legacy CLI: https://github.com/databricks/databricks-cli
|
|
|
|
Aliases: []string{"mkdirs"},
|
2024-02-20 16:14:37 +00:00
|
|
|
Short: "Make directories.",
|
|
|
|
Long: `Make directories in DBFS and UC Volumes. Mkdir will create directories along the path to the argument directory.`,
|
2023-07-27 10:03:08 +00:00
|
|
|
Args: cobra.ExactArgs(1),
|
|
|
|
PreRunE: root.MustWorkspaceClient,
|
|
|
|
}
|
2023-06-12 12:05:56 +00:00
|
|
|
|
2023-07-27 10:03:08 +00:00
|
|
|
cmd.RunE = func(cmd *cobra.Command, args []string) error {
|
2023-06-12 12:05:56 +00:00
|
|
|
ctx := cmd.Context()
|
|
|
|
|
2023-06-16 15:09:08 +00:00
|
|
|
f, path, err := filerForPath(ctx, args[0])
|
2023-06-12 12:05:56 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return f.Mkdir(ctx, path)
|
2023-07-27 10:03:08 +00:00
|
|
|
}
|
2023-06-12 12:05:56 +00:00
|
|
|
|
2023-07-27 10:03:08 +00:00
|
|
|
return cmd
|
2023-06-12 12:05:56 +00:00
|
|
|
}
|