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

Implicit help short replacement no longer works in v4 #4311

Closed
2 tasks done
TitanNano opened this issue Sep 30, 2022 · 1 comment
Closed
2 tasks done

Implicit help short replacement no longer works in v4 #4311

TitanNano opened this issue Sep 30, 2022 · 1 comment
Labels
C-bug Category: Updating dependencies

Comments

@TitanNano
Copy link

Please complete the following tasks

Rust Version

rustc 1.63.0 (4b91a6ea7 2022-08-08)

Clap Version

clap v4.0.6

Minimal reproducible code

use clap::Parser;

#[derive(Debug, Parser)]
#[clap(version, author)]
struct Args {
    #[clap(long, short)]
    host: String,
}

fn main() {
    let args = Args::parse();
    
    println!("{:?}", args);
}

Steps to reproduce the bug with the above code

  1. 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.

https://docs.rs/clap/latest/clap/builder/struct.Arg.html#method.short

Debug Output

     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
@TitanNano TitanNano added the C-bug Category: Updating dependencies label Sep 30, 2022
epage added a commit to epage/clap that referenced this issue Sep 30, 2022
@epage
Copy link
Member

epage commented Sep 30, 2022

This is a duplicate of #4304. See that for more details

As for the stale documentation, that is being updated in #4312

@epage epage closed this as completed Sep 30, 2022
epage added a commit to epage/clap that referenced this issue Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Updating dependencies
Projects
None yet
Development

No branches or pull requests

2 participants