Skip to content

Commit

Permalink
allow to not check flags with --yes/-y
Browse files Browse the repository at this point in the history
Signed-off-by: Yves Brissaud <[email protected]>
  • Loading branch information
eunomie committed Oct 15, 2024
1 parent d3713d0 commit bbc5089
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions internal/commands/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ import (
)

var (
docs bool
list bool
ask bool
opts []string
docs bool
list bool
ask bool
opts []string
noFlagCheck bool
)

func NewCmd(dockerCli command.Cli, isPlugin bool) *cobra.Command {
Expand Down Expand Up @@ -171,6 +172,7 @@ func NewCmd(dockerCli command.Cli, isPlugin bool) *cobra.Command {
f.BoolVarP(&list, "list", "l", false, "List available actions")
f.BoolVar(&ask, "ask", false, "Do not read local configuration option values and always ask them")
f.StringArrayVar(&opts, "opt", nil, "Set an option value")
f.BoolVarP(&noFlagCheck, "yes", "y", false, "Do not check flags before running the command")

return cmd
}
Expand Down Expand Up @@ -235,7 +237,11 @@ func run(ctx context.Context, out io.Writer, src string, rk *runkit.RunKit, acti
---
`, runnable.Command)

if flags, err := runnable.CheckFlags(); err != nil {
var flags []string
if !noFlagCheck {
flags, err = runnable.CheckFlags()
}
if err != nil {
return err
} else if len(flags) > 0 {
_, _ = fmt.Fprintln(out, tui.Markdown(mdCommand+fmt.Sprintf(`
Expand Down

0 comments on commit bbc5089

Please sign in to comment.