From 63df93c1a1ab2aec3c0ecc464c1a12e557044c50 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Wed, 21 Jun 2023 18:40:15 +0200 Subject: [PATCH] Make instance path a required arg --- cmd/bundle/init.go | 8 +++----- internal/init_test.go | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/cmd/bundle/init.go b/cmd/bundle/init.go index 40f9829b1..a1540369d 100644 --- a/cmd/bundle/init.go +++ b/cmd/bundle/init.go @@ -6,20 +6,18 @@ import ( ) var initCmd = &cobra.Command{ - Use: "init", + Use: "init TEMPLATE_PATH INSTANCE_PATH", Short: "Initialize Template", Long: `Initialize template`, - Args: cobra.ExactArgs(1), + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { - return template.Materialize(args[0], targetDir, configFile) + return template.Materialize(args[0], args[1], configFile) }, } -var targetDir string var configFile string func init() { - initCmd.Flags().StringVar(&targetDir, "target-dir", ".", "path to directory template will be initialized in") initCmd.Flags().StringVar(&configFile, "config-file", "", "path to config to use for template initialization") initCmd.MarkFlagRequired("config-file") AddCommand(initCmd) diff --git a/internal/init_test.go b/internal/init_test.go index 58c48a03c..6d37fa141 100644 --- a/internal/init_test.go +++ b/internal/init_test.go @@ -36,7 +36,7 @@ func TestTemplateInitializationForDevConfig(t *testing.T) { // materialize the template cmd := root.RootCmd - cmd.SetArgs([]string{"bundle", "init", filepath.FromSlash("testdata/init/templateDefinition"), "--target-dir", tmp, "--config-file", filepath.Join(tmp, "config.json")}) + cmd.SetArgs([]string{"bundle", "init", filepath.FromSlash("testdata/init/templateDefinition"), tmp, "--config-file", filepath.Join(tmp, "config.json")}) err = cmd.Execute() require.NoError(t, err) @@ -78,7 +78,7 @@ func TestTemplateInitializationForProdConfig(t *testing.T) { cmd := root.RootCmd childCommands := cmd.Commands() fmt.Println(childCommands) - cmd.SetArgs([]string{"bundle", "init", filepath.FromSlash("testdata/init/templateDefinition"), "--target-dir", instanceDir, "--config-file", filepath.Join(configDir, "my_config.json")}) + cmd.SetArgs([]string{"bundle", "init", filepath.FromSlash("testdata/init/templateDefinition"), instanceDir, "--config-file", filepath.Join(configDir, "my_config.json")}) err = cmd.Execute() require.NoError(t, err)