diff --git a/cmd/fs.go b/cmd/fs.go new file mode 100644 index 00000000..bb113cb0 --- /dev/null +++ b/cmd/fs.go @@ -0,0 +1,26 @@ +package cmd + +import ( + "github.com/spf13/cobra" +) + +// fsCmd represents the fs command +var fsCmd = &cobra.Command{ + Use: "fs", + Short: "Filesystem related commands", + Long: `Commands to do DBFS operations.`, +} + +func init() { + rootCmd.AddCommand(fsCmd) + + // Here you will define your flags and configuration settings. + + // Cobra supports Persistent Flags which will work for this command + // and all subcommands, e.g.: + // fsCmd.PersistentFlags().String("foo", "", "A help for foo") + + // Cobra supports local flags which will only run when this command + // is called directly, e.g.: + // fsCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") +} diff --git a/cmd/ls.go b/cmd/ls.go new file mode 100644 index 00000000..33113f53 --- /dev/null +++ b/cmd/ls.go @@ -0,0 +1,42 @@ +package cmd + +import ( + "fmt" + + "github.com/databricks/bricks/project" + "github.com/spf13/cobra" + + "github.com/databrickslabs/terraform-provider-databricks/storage" +) + +// lsCmd represents the ls command +var lsCmd = &cobra.Command{ + Use: "ls", + Short: "Lists files", + Long: `Lists files`, + Args: cobra.ExactArgs(1), + Run: func(cmd *cobra.Command, args []string) { + api := storage.NewDbfsAPI(cmd.Context(), project.ClientFromContext(cmd.Context())) + files, err := api.List(args[0], false) + if err != nil { + panic(err) + } + for _, v := range files { + fmt.Printf("[-] %s (%d, %v)\n", v.Path, v.FileSize, v.IsDir) + } + }, +} + +func init() { + fsCmd.AddCommand(lsCmd) + + // Here you will define your flags and configuration settings. + + // Cobra supports Persistent Flags which will work for this command + // and all subcommands, e.g.: + // lsCmd.PersistentFlags().String("foo", "", "A help for foo") + + // Cobra supports local flags which will only run when this command + // is called directly, e.g.: + // lsCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") +} diff --git a/cmd/test.go b/cmd/test.go index 664ffb00..b3c1aecb 100644 --- a/cmd/test.go +++ b/cmd/test.go @@ -13,7 +13,6 @@ var testCmd = &cobra.Command{ Short: "run tests for the project", Long: `This is longer description of the command`, Run: func(cmd *cobra.Command, args []string) { - results := project.RunPythonOnDev(cmd.Context(), `print("hello, world!")`) if results.Failed() { log.Fatal(results.Error())