Skip to content

Commit

Permalink
Subtle fix: update && not required should not prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
cyx committed Mar 20, 2021
1 parent 4819ea8 commit 25a1c89
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@ func registerBool(cmd *cobra.Command, f *Flag, value *bool, defaultValue bool, i
}
}

func shouldAsk(cmd *cobra.Command, f *Flag, isUpdate bool) bool {
if isUpdate {
if !f.IsRequired {
return false
}

return shouldPromptWhenFlagless(cmd, f.LongForm)
}

return shouldPrompt(cmd, f.LongForm)
}

func markFlagRequired(cmd *cobra.Command, f *Flag, isUpdate bool) error {
if f.IsRequired && !isUpdate {
return cmd.MarkFlagRequired(f.LongForm)
Expand Down

0 comments on commit 25a1c89

Please sign in to comment.