databricks-cli/cmd/bundle/init.go

32 lines
824 B
Go
Raw Normal View History

package bundle
2023-05-15 09:25:01 +00:00
import (
2023-05-21 20:48:38 +00:00
"path/filepath"
2023-05-17 12:07:57 +00:00
"github.com/databricks/cli/libs/template"
2023-05-15 09:25:01 +00:00
"github.com/spf13/cobra"
)
var initCmd = &cobra.Command{
Use: "init",
Short: "Initialize Template",
2023-05-17 00:43:41 +00:00
Long: `Initialize template`,
Args: cobra.ExactArgs(1),
2023-05-15 09:25:01 +00:00
RunE: func(cmd *cobra.Command, args []string) error {
2023-05-21 20:48:38 +00:00
// initialize default value for config file path
if configFile == "" {
configFile = filepath.Join(targetDir, template.ConfigFileName)
}
2023-05-22 03:58:05 +00:00
return template.Materialize(args[0], targetDir, configFile)
2023-05-15 09:25:01 +00:00
},
}
2023-05-17 11:41:15 +00:00
var targetDir string
2023-05-21 20:48:38 +00:00
var configFile string
2023-05-17 11:41:15 +00:00
2023-05-15 09:25:01 +00:00
func init() {
2023-05-17 11:41:15 +00:00
initCmd.Flags().StringVar(&targetDir, "target-dir", ".", "path to directory template will be initialized in")
2023-05-21 20:48:38 +00:00
initCmd.Flags().StringVar(&configFile, "config-file", "", "path to config to use for template initialization")
AddCommand(initCmd)
2023-05-15 09:25:01 +00:00
}