diff --git a/cmd/bundle/launch.go b/cmd/bundle/launch.go new file mode 100644 index 00000000..2f748b78 --- /dev/null +++ b/cmd/bundle/launch.go @@ -0,0 +1,37 @@ +package bundle + +import ( + "fmt" + + "github.com/databricks/bricks/cmd/root" + "github.com/spf13/cobra" +) + +var launchCmd = &cobra.Command{ + Use: "launch", + Short: "Launches a notebook on development cluster", + Long: `Reads a file and executes it on dev cluster`, + Args: cobra.ExactArgs(1), + + // We're not ready to expose this command until we specify its semantics. + Hidden: true, + + PreRunE: root.MustConfigureBundle, + RunE: func(cmd *cobra.Command, args []string) error { + return fmt.Errorf("TODO") + // contents, err := os.ReadFile(args[0]) + // if err != nil { + // return err + // } + // results := project.RunPythonOnDev(cmd.Context(), string(contents)) + // if results.Failed() { + // return results.Err() + // } + // fmt.Fprintf(cmd.OutOrStdout(), "Success: %s", results.Text()) + // return nil + }, +} + +func init() { + AddCommand(launchCmd) +} diff --git a/cmd/bundle/test.go b/cmd/bundle/test.go new file mode 100644 index 00000000..1e6c09aa --- /dev/null +++ b/cmd/bundle/test.go @@ -0,0 +1,32 @@ +package bundle + +import ( + "fmt" + + "github.com/databricks/bricks/cmd/root" + "github.com/spf13/cobra" +) + +var testCmd = &cobra.Command{ + Use: "test", + Short: "run tests for the project", + Long: `This is longer description of the command`, + + // We're not ready to expose this command until we specify its semantics. + Hidden: true, + + PreRunE: root.MustConfigureBundle, + RunE: func(cmd *cobra.Command, args []string) error { + return fmt.Errorf("TODO") + // results := project.RunPythonOnDev(cmd.Context(), `return 1`) + // if results.Failed() { + // return results.Err() + // } + // fmt.Fprintf(cmd.OutOrStdout(), "Success: %s", results.Text()) + // return nil + }, +} + +func init() { + AddCommand(testCmd) +} diff --git a/cmd/launch/launch.go b/cmd/launch/launch.go deleted file mode 100644 index 402a6963..00000000 --- a/cmd/launch/launch.go +++ /dev/null @@ -1,36 +0,0 @@ -package launch - -import ( - "fmt" - "log" - "os" - - "github.com/databricks/bricks/cmd/root" - "github.com/databricks/bricks/project" - "github.com/spf13/cobra" -) - -// launchCmd represents the launch command -var launchCmd = &cobra.Command{ - Use: "launch", - Short: "Launches a notebook on development cluster", - Long: `Reads a file and executes it on dev cluster`, - Args: cobra.ExactArgs(1), - Run: func(cmd *cobra.Command, args []string) { - contents, err := os.ReadFile(args[0]) - if err != nil { - log.Fatal(err) - } - results := project.RunPythonOnDev(cmd.Context(), string(contents)) - if results.Failed() { - log.Fatal(results.Error()) - } - fmt.Println(results.Text()) - }, -} - -func init() { - // TODO: detect if we can skip registering - // launch command for DBSQL projects - root.RootCmd.AddCommand(launchCmd) -} diff --git a/cmd/test/test.go b/cmd/test/test.go deleted file mode 100644 index 33a0a6e1..00000000 --- a/cmd/test/test.go +++ /dev/null @@ -1,37 +0,0 @@ -package test - -import ( - "log" - - "github.com/databricks/bricks/cmd/root" - "github.com/databricks/bricks/project" - "github.com/spf13/cobra" -) - -// testCmd represents the test command -var testCmd = &cobra.Command{ - Use: "test", - 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(), `return 1`) - if results.Failed() { - log.Fatal(results.Error()) - } - log.Printf("Success: %s", results.Text()) - }, -} - -func init() { - root.RootCmd.AddCommand(testCmd) - - // Here you will define your flags and configuration settings. - - // Cobra supports Persistent Flags which will work for this command - // and all subcommands, e.g.: - // testCmd.PersistentFlags().String("foo", "", "A help for foo") - - // Cobra supports local flags which will only run when this command - // is called directly, e.g.: - // testCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") -} diff --git a/main.go b/main.go index a3131c4d..b0fc5d7e 100644 --- a/main.go +++ b/main.go @@ -9,10 +9,8 @@ import ( _ "github.com/databricks/bricks/cmd/configure" _ "github.com/databricks/bricks/cmd/fs" _ "github.com/databricks/bricks/cmd/init" - _ "github.com/databricks/bricks/cmd/launch" "github.com/databricks/bricks/cmd/root" _ "github.com/databricks/bricks/cmd/sync" - _ "github.com/databricks/bricks/cmd/test" _ "github.com/databricks/bricks/cmd/version" )