-
Notifications
You must be signed in to change notification settings - Fork 263
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
Document boolean flags by presence #283
Document boolean flags by presence #283
Conversation
the flag *disables* a default behavior which is to do something, it should | ||
start with `no` (eg. `--no-generate-name` when the default is to generate a | ||
name). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, both variations (with and without --no
) should be present in this case, regardless of the default value (using the variant that corresponds to the default value should be possible, too). In this example, e.g. --generate-name
and --no-generate-name
should be both available all the time (corresponding --generate-name=true
and --generate-name=false
).
The reason why I prefer this variant is:
- There is no ambiguity what should be used as boolean value ("true", "yes" and "on" are commonly used as such values), where "true" is probably mostly accustomed for programmers (maybe not so much users of
kn
?) - It's shorter without specifying the value
- It stands in the tradition of GNU getopts (sometimes you see the variation
--with-
and--no-
for true and false) - Many boolean options are modelled like this in Unix (they are called 'flags' in this case. Eg.:
ls -l
) - We already use that style e.g. for
kn --help
(or would we like to switch tokn --help=true
?). Other examples:kn service create --force
orkn service create --async
would have change tokn service create --force=true
andkn service create --async=true
(or maybe in the latter case--sync=false
) - For consistencies reasons we would always have to require options with values then, which might lead to an unnecessarily bloated UI (because you can't use simple flags anymore).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, both variations (with and without --no) should be present in this case, regardless of the default value (using the variant that corresponds to the default value should be possible, too).
I have the same feeling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just noticed your statement here:
We already use that style e.g. for kn --help (or would we like to switch to kn --help=true ?). Other examples: kn service create --force or kn service create --async would have change to kn service create --force=true and kn service create --async=true (or maybe in the latter case --sync=false)
--help
continues to work as cobra defaults it to mean true
. so full form --flag=false
is only necessary when turning things off.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cppforlife Have you tried My bad, it works as expected (no arg == help). You can use kn --help=false
?kn service list --help=false
, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: maximilien, sixolet The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
I think the most compelling argument made was:
The use of Either PR can work though... my only really BIG sore point is if we allow |
Add documentation that boolean flags should be specified by flag presence.
This is mutally exclusive with #284 .
Vote by thumbs up reaction emoji. Winner gets merged.