Skip to content

Commit

Permalink
Merge pull request #343 from kosli-dev/340-fix-bug-in-require-flags-f…
Browse files Browse the repository at this point in the history
…unction

Detect missing flag when flag can have repeats
  • Loading branch information
JonJagger authored Oct 7, 2024
2 parents 6689238 + d20cf99 commit 7c9219d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/kosli/cli_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ func DefaultValueForCommit(ci string, returnHead bool) string {
// RequireFlags declares a list of flags as required for a given command
func RequireFlags(cmd *cobra.Command, flagNames []string) error {
for _, name := range flagNames {
if cmd.Flags().Lookup(name).DefValue == "" {
defaultValue := cmd.Flags().Lookup(name).DefValue
if defaultValue == "" || defaultValue == "[]" {
err := cobra.MarkFlagRequired(cmd.Flags(), name)
if err != nil {
return err
Expand Down

0 comments on commit 7c9219d

Please sign in to comment.