You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use clap::Parser;#[derive(Debug,Parser)]#[clap(version, author)]structArgs{#[clap(long, short)]host:String,}fnmain(){let args = Args::parse();println!("{:?}", args);}
Steps to reproduce the bug with the above code
cargo run
Actual Behaviour
Running `target/debug/clap4-test`
thread 'main' panicked at 'Command clap4-test: Short option names must be unique for each argument, but '-h' is in use by both 'host' and 'help' (call `cmd.disable_help_flag(true)` to remove the auto-generated `--help`)', /.cargo/registry/src/github.com-1ecc6299db9ec823/clap-4.0.6/src/builder/debug_asserts.rs:121:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Expected Behaviour
i.e. clap v3
Running `target/debug/clap4-test`
error: The following required arguments were not provided:
--host <HOST>
USAGE:
clap4-test --host <HOST>
For more information try --help
Additional Context
When defining an attribute with the same short value as help, i.e. h the arg no longer replaces the help attribute, but creates a conflict. This worked in clap 3 and according to the latest docs, this should still be the case.
Running `target/debug/clap4-test`
[ clap::builder::command] Command::_do_parse
[ clap::builder::command] Command::_build: name="clap4-test"
[ clap::builder::command] Command::_propagate:clap4-test
[ clap::builder::command] Command::_check_help_and_version:clap4-test expand_help_tree=false
[ clap::builder::command] Command::long_help_exists
[ clap::builder::command] Command::_check_help_and_version: Building default --help
[ clap::builder::command] Command::_check_help_and_version: Building default --version
[ clap::builder::command] Command::_propagate_global_args:clap4-test
[clap::builder::debug_asserts] Command::_debug_asserts
[clap::builder::debug_asserts] Arg::_debug_asserts:host
thread 'main' panicked at 'Command clap4-test: Short option names must be unique for each argument, but '-h' is in use by both 'host' and 'help' (call `cmd.disable_help_flag(true)` to remove the auto-generated `--help`)', /Users/jovan/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-4.0.6/src/builder/debug_asserts.rs:121:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The text was updated successfully, but these errors were encountered:
Please complete the following tasks
Rust Version
rustc 1.63.0 (4b91a6ea7 2022-08-08)
Clap Version
clap v4.0.6
Minimal reproducible code
Steps to reproduce the bug with the above code
Actual Behaviour
Expected Behaviour
i.e. clap v3
Additional Context
When defining an attribute with the same short value as help, i.e.
h
the arg no longer replaces the help attribute, but creates a conflict. This worked in clap 3 and according to the latest docs, this should still be the case.https://docs.rs/clap/latest/clap/builder/struct.Arg.html#method.short
Debug Output
The text was updated successfully, but these errors were encountered: