databricks-cli/cmd/launch/launch.go

37 lines
812 B
Go
Raw Permalink Normal View History

2022-05-14 17:54:35 +00:00
package launch
import (
"fmt"
"log"
"os"
2022-05-14 17:54:35 +00:00
"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
2022-05-16 10:50:50 +00:00
// launch command for DBSQL projects
2022-05-14 17:54:35 +00:00
root.RootCmd.AddCommand(launchCmd)
}