Merge pull request #505 from samalba/gitflow-help

Gitflow help
This commit is contained in:
Sam Alba
2021-05-27 00:36:53 -07:00
committed by GitHub
5 changed files with 78 additions and 42 deletions

View File

@@ -10,8 +10,9 @@ import (
)
var initCmd = &cobra.Command{
Use: "init",
Args: cobra.MaximumNArgs(1),
Use: "init",
Short: "Initialize a new empty workspace",
Args: cobra.NoArgs,
PreRun: func(cmd *cobra.Command, args []string) {
// Fix Viper bug for duplicate flags:
// https://github.com/spf13/viper/issues/233
@@ -35,10 +36,12 @@ var initCmd = &cobra.Command{
dir = cwd
}
_, err := state.Init(ctx, dir)
ws, err := state.Init(ctx, dir)
if err != nil {
lg.Fatal().Err(err).Msg("failed to initialize workspace")
}
lg.Info().Str("path", ws.DaggerDir()).Msg("initialized new empty workspace")
},
}

View File

@@ -21,7 +21,7 @@ import (
var listCmd = &cobra.Command{
Use: "list [TARGET] [flags]",
Short: "List for the inputs of an environment",
Short: "List the inputs of an environment",
Args: cobra.MaximumNArgs(1),
PreRun: func(cmd *cobra.Command, args []string) {
// Fix Viper bug for duplicate flags:

View File

@@ -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,8 +10,9 @@ import (
)
var newCmd = &cobra.Command{
Use: "new",
Args: cobra.ExactArgs(1),
Use: "new <NAME>",
Short: "Create a new empty environment",
Args: cobra.ExactArgs(1),
PreRun: func(cmd *cobra.Command, args []string) {
// Fix Viper bug for duplicate flags:
// https://github.com/spf13/viper/issues/233
@@ -29,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))
},
}