From 97be7b917a6a8fe0b76bed49e6c39015c71e9a76 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Wed, 26 May 2021 17:41:37 +0200 Subject: [PATCH] cmd/new+init: added instructions for new + fix for init arg Signed-off-by: Sam Alba --- cmd/dagger/cmd/init.go | 2 +- cmd/dagger/cmd/new.go | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/dagger/cmd/init.go b/cmd/dagger/cmd/init.go index aa89d9fe..ca6a4f84 100644 --- a/cmd/dagger/cmd/init.go +++ b/cmd/dagger/cmd/init.go @@ -12,7 +12,7 @@ import ( var initCmd = &cobra.Command{ Use: "init", Short: "Initialize a new empty workspace", - Args: cobra.MaximumNArgs(1), + Args: cobra.NoArgs, PreRun: func(cmd *cobra.Command, args []string) { // Fix Viper bug for duplicate flags: // https://github.com/spf13/viper/issues/233 diff --git a/cmd/dagger/cmd/new.go b/cmd/dagger/cmd/new.go index 96371951..8f32cb50 100644 --- a/cmd/dagger/cmd/new.go +++ b/cmd/dagger/cmd/new.go @@ -1,6 +1,8 @@ package cmd import ( + "fmt" + "github.com/spf13/cobra" "github.com/spf13/viper" "go.dagger.io/dagger/cmd/dagger/cmd/common" @@ -8,7 +10,7 @@ import ( ) var newCmd = &cobra.Command{ - Use: "new", + Use: "new ", Short: "Create a new empty environment", Args: cobra.ExactArgs(1), PreRun: func(cmd *cobra.Command, args []string) { @@ -30,9 +32,13 @@ var newCmd = &cobra.Command{ Msg("cannot use option -e,--environment for this command") } name := args[0] - if _, err := workspace.Create(ctx, name); err != nil { + ws, err := workspace.Create(ctx, name) + if err != nil { lg.Fatal().Err(err).Msg("failed to create environment") } + + lg.Info().Str("name", name).Msg("created new empty environment") + lg.Info().Str("name", name).Msg(fmt.Sprintf("to add code to the plan, copy or create cue files under: %s", ws.Plan)) }, }