databricks-cli/cmd/root.go

49 lines
1.4 KiB
Go

package cmd
import (
"context"
"os"
"time"
"github.com/databricks/bricks/project"
"github.com/spf13/cobra"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "bricks",
Short: "Databricks project lifecycle management",
Long: `Where's "data"? Secured by the unity catalog. Projects build lifecycle is secured by bricks`,
// Uncomment the following line if your bare application
// has an action associated with it:
// Run: func(cmd *cobra.Command, args []string) { },
}
// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
ctx := project.Authenticate(context.Background())
err := rootCmd.ExecuteContext(ctx)
if err != nil {
os.Exit(1)
}
}
func init() {
// Here you will define your flags and configuration settings.
// Cobra supports persistent flags, which, if defined here,
// will be global for your application.
// rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.bricks.yaml)")
// Cobra also supports local flags, which will only run
// when this action is called directly.
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
zerolog.DurationFieldUnit = time.Second
}