-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bool flags accept a value but do not mention taking arguments in --help output #1657
Comments
If you're looking for a single "switch" flag, you'll want something like this: var bark bool
...
// use false, the "empty" value for a bool, as the default
rootCmd.PersistentFlags().BoolVarP(&bark, "woof", "", false, "prints out bark")
...
// In your command logic, use that variable
if bark {
println("woof!")
} Running this program looks like:
|
I am not looking for a switch flag, rather that (in your example), |
A bool flag is a switch flag.
Are you expecting that the default template for bool flags should mention that it's expecting a bool? Or am I missing something here? |
I expect the --help output to tell me that
ofc, I'm not asking for removal of |
I think that's fair! Re-opening and we can get some community feedback |
The Cobra project currently lacks enough contributors to adequately respond to all issues. This bot triages issues and PRs according to the following rules:
|
bump. This issue bit me today, as I expected it to function as |
Given a bool flag like
--help
lists:but the parser accepts
--frobnicate false
, expected behaviour is to either disallow--frobnicate false
or mention the optional argument in--help
likeThe text was updated successfully, but these errors were encountered: