Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@alissonbrunosa
Copy link
Contributor

What?

It makes the error message for the gh release create command clearer when a tag name is not passed in

It fixes #2327

Comment on lines +80 to +86
Args: func(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
return nil
}

return &cmdutil.FlagError{Err: errors.New("could not create: no tag name provided")}
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we have a couple of those custom messages already. Should we create something like:

func MinimumArgs(n int, msg string) cobra.PositionalArgs {
        if msg == "" {
                return cobra.MinimumNArgs(1)
        }

  	return func(cmd *Command, args []string) error {
		if len(args) < n {
			return &cmdutil.FlagError{Err: errors.New(msg)}
		}
		return nil
	}
}

and we could use like:

Args: cmdutil.MinimumArgs(1, "could not create: no tag name provided")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea; happy for that to be a follow-up, though.

Copy link
Contributor

@vilmibm vilmibm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@vilmibm vilmibm merged commit 9100633 into cli:trunk Nov 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

:gh release create: Make the error message more descriptive, if <tag> isn't passed.

2 participants