Skip to content
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

[BUG] Boolean arg swallows following arg if it is false or true #72

Open
cspotcode opened this issue Dec 5, 2016 · 0 comments
Open
Labels
Bug thing that needs fixing

Comments

@cspotcode
Copy link

Boolean options should not swallow the following argument if it is false or true. This can occur coincidentally and is probably not what the user wants.

Consider a CLI tool that outputs the size of files, where each file is passed as a positional argument. The -h or --human flag causes it to output human-friendly values. ("1KB" instead of "1024")

$ file-sizes -h *
file-1 1MB
file-2 2.3MB

Now imagine that the files in CWD are "false", "foo", and "bar"

$ file-sizes -h *
foo 1035
bar 345
# Errors: -h flag isn't set; "false" is omitted

For this reason, boolean options should never interpret the following argument as their value.

# following positional argument should *never* be interpreted as a value for the `--human` flag
file-sizes --human true

Users can still pass --human, --no-human, --human=true, or --human=false to explicitly set the flag to true or false.

@darcyclarke darcyclarke changed the title Boolean arg swallows following arg if it is false or true [BUG] Boolean arg swallows following arg if it is false or true Jul 28, 2022
@darcyclarke darcyclarke added the Bug thing that needs fixing label Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing
Projects
None yet
Development

No branches or pull requests

2 participants