-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
ignore_errors
makes boolean flag required in clap 4
#4391
Comments
You can work around this by switching to an I'm assuming you can reproduce this in clap v3 if you add The workaround works because the error is coming from My guess is that in at least some cases of ignore_errors, we are not processing defaults. This means the problem would be the same if you did We should probably be making sure we populate defaults with |
Clap bails parsing when an "error" is encountered, e.g. a subcommand is missing, "--help" is passed, or the "help" subcommand is invoked. This means that the current approach of parsing args does not handle flags like `--no-pager` or `--color` when an error is encountered. Fix this by separating early args into their own struct and preprocessing them using `ignore_errors` (per clap-rs/clap#1880). The early args are in a new `EarlyArgs` struct because of a known bug where `ignore_errors` causes default values not to be respected (clap-rs/clap#4391 specifically calls out bool, but strings may also be ignored), so when `ignore_errors` is given, the default values will be missing and parsing will fail unless the right arg types are used (e.g`. Option`). By parsing only early args (using the new struct) we only need to adjust `no_pager`, instead of adjusting all args with a default value.
Clap bails parsing when an "error" is encountered, e.g. a subcommand is missing, "--help" is passed, or the "help" subcommand is invoked. This means that the current approach of parsing args does not handle flags like `--no-pager` or `--color` when an error is encountered. Fix this by separating early args into their own struct and preprocessing them using `ignore_errors` (per clap-rs/clap#1880). The early args are in a new `EarlyArgs` struct because of a known bug where `ignore_errors` causes default values not to be respected (clap-rs/clap#4391 specifically calls out bool, but strings may also be ignored), so when `ignore_errors` is given, the default values will be missing and parsing will fail unless the right arg types are used (e.g`. Option`). By parsing only early args (using the new struct) we only need to adjust `no_pager`, instead of adjusting all args with a default value.
Clap bails parsing when an "error" is encountered, e.g. a subcommand is missing, "--help" is passed, or the "help" subcommand is invoked. This means that the current approach of parsing args does not handle flags like `--no-pager` or `--color` when an error is encountered. Fix this by separating early args into their own struct and preprocessing them using `ignore_errors` (per clap-rs/clap#1880). The early args are in a new `EarlyArgs` struct because of a known bug where `ignore_errors` causes default values not to be respected (clap-rs/clap#4391 specifically calls out bool, but strings may also be ignored), so when `ignore_errors` is given, the default values will be missing and parsing will fail unless the right arg types are used (e.g`. Option`). By parsing only early args (using the new struct) we only need to adjust `no_pager`, instead of adjusting all args with a default value.
Clap bails parsing when an "error" is encountered, e.g. a subcommand is missing, "--help" is passed, or the "help" subcommand is invoked. This means that the current approach of parsing args does not handle flags like `--no-pager` or `--color` when an error is encountered. Fix this by separating early args into their own struct and preprocessing them using `ignore_errors` (per clap-rs/clap#1880). The early args are in a new `EarlyArgs` struct because of a known bug where `ignore_errors` causes default values not to be respected (clap-rs/clap#4391 specifically calls out bool, but strings may also be ignored), so when `ignore_errors` is given, the default values will be missing and parsing will fail unless the right arg types are used (e.g`. Option`). By parsing only early args (using the new struct) we only need to adjust `no_pager`, instead of adjusting all args with a default value.
Clap bails parsing when an "error" is encountered, e.g. a subcommand is missing, "--help" is passed, or the "help" subcommand is invoked. This means that the current approach of parsing args does not handle flags like `--no-pager` or `--color` when an error is encountered. Fix this by separating early args into their own struct and preprocessing them using `ignore_errors` (per clap-rs/clap#1880). The early args are in a new `EarlyArgs` struct because of a known bug where `ignore_errors` causes default values not to be respected (clap-rs/clap#4391 specifically calls out bool, but strings may also be ignored), so when `ignore_errors` is given, the default values will be missing and parsing will fail unless the right arg types are used (e.g`. Option`). By parsing only early args (using the new struct) we only need to adjust `no_pager`, instead of adjusting all args with a default value.
Clap bails parsing when an "error" is encountered, e.g. a subcommand is missing, "--help" is passed, or the "help" subcommand is invoked. This means that the current approach of parsing args does not handle flags like `--no-pager` or `--color` when an error is encountered. Fix this by separating early args into their own struct and preprocessing them using `ignore_errors` (per clap-rs/clap#1880). The early args are in a new `EarlyArgs` struct because of a known bug where `ignore_errors` causes default values not to be respected (clap-rs/clap#4391 specifically calls out bool, but strings may also be ignored), so when `ignore_errors` is given, the default values will be missing and parsing will fail unless the right arg types are used (e.g`. Option`). By parsing only early args (using the new struct) we only need to adjust `no_pager`, instead of adjusting all args with a default value.
Please complete the following tasks
Rust Version
rustc 1.66.0-nightly (e7119a030 2022-09-22)
Clap Version
4.0.15
Minimal reproducible code
Steps to reproduce the bug with the above code
cargo run -- --help
Actual Behaviour
Expected Behaviour
Additional Context
The expected behavior occurs in version 3.2.22.
Debug Output
The text was updated successfully, but these errors were encountered: