diff --git a/internal/cli/cli.go b/internal/cli/cli.go index 944584d3c..f788f81c2 100644 --- a/internal/cli/cli.go +++ b/internal/cli/cli.go @@ -536,16 +536,15 @@ func shouldPrompt(cmd *cobra.Command, flag *Flag) bool { return canPrompt(cmd) && !flag.IsSet(cmd) } -func shouldPromptWhenFlagless(cmd *cobra.Command, flag string) bool { - isSet := false - +func shouldPromptWhenNoLocalFlagsSet(cmd *cobra.Command) bool { + localFlagIsSet := false cmd.LocalFlags().VisitAll(func(f *pflag.Flag) { - if f.Changed { - isSet = true + if f.Name != "json" && f.Name != "force" && f.Changed { + localFlagIsSet = true } }) - return canPrompt(cmd) && !isSet + return canPrompt(cmd) && !localFlagIsSet } func prepareInteractivity(cmd *cobra.Command) { diff --git a/internal/cli/flags.go b/internal/cli/flags.go index 08837f1c9..dff59a540 100644 --- a/internal/cli/flags.go +++ b/internal/cli/flags.go @@ -285,7 +285,7 @@ func shouldAsk(cmd *cobra.Command, f *Flag, isUpdate bool) bool { if !f.IsRequired && !f.AlwaysPrompt { return false } - return shouldPromptWhenFlagless(cmd, f.LongForm) + return shouldPromptWhenNoLocalFlagsSet(cmd) } return shouldPrompt(cmd, f)