Skip to content

Commit

Permalink
Use standardised flag; not camel case (#401)
Browse files Browse the repository at this point in the history
* Use standardised flag; not camel case

* Catch the error
  • Loading branch information
mcncl authored Nov 20, 2024
1 parent 480215a commit af15027
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/cmd/build/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/buildkite/go-buildkite/v4"
"github.com/charmbracelet/huh/spinner"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

func NewCmdBuildNew(f *factory.Factory) *cobra.Command {
Expand Down Expand Up @@ -99,7 +100,10 @@ func NewCmdBuildNew(f *factory.Factory) *cobra.Command {
cmd.Flags().StringArrayVarP(&env, "env", "e", []string{}, "Set environment variables for the build")
cmd.Flags().BoolVarP(&ignoreBranchFilters, "ignore-branch-filters", "i", false, "Ignore branch filters for the pipeline")
cmd.Flags().BoolVarP(&confirmed, "yes", "y", false, "Skip the confirmation prompt. Useful if being used in automation/CI")
cmd.Flags().StringVarP(&envFile, "envFile", "f", "", "Set the environment variables for the build via an environment file")
cmd.Flags().StringVarP(&envFile, "env-file", "f", "", "Set the environment variables for the build via an environment file")
cmd.Flags().StringVarP(&envFile, "envFile", "", "", "Set the environment variables for the build via an environment file")
_ = cmd.Flags().MarkDeprecated("envFile", "use --env-file instead")
cmd.Flags().SetNormalizeFunc(normaliseFlags)
cmd.Flags().SortFlags = false
return &cmd
}
Expand Down Expand Up @@ -145,3 +149,11 @@ func newBuild(ctx context.Context, org string, pipeline string, f *factory.Facto

return util.OpenInWebBrowser(web, build.WebURL)
}

func normaliseFlags(pf *pflag.FlagSet, name string) pflag.NormalizedName {
switch name {
case "envFile":
name = "env-file"
}
return pflag.NormalizedName(name)
}

0 comments on commit af15027

Please sign in to comment.