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

Using help_heading in one place requires using it on all Flags to get a Unified experience #2847

Closed
2 tasks done
epage opened this issue Oct 11, 2021 · 0 comments · Fixed by #2867
Closed
2 tasks done
Labels
A-help Area: documentation, including docs.rs, readme, examples, etc... C-bug Category: Updating dependencies
Milestone

Comments

@epage
Copy link
Member

epage commented Oct 11, 2021

Please complete the following tasks

  • I have searched the discussions
  • I have searched the existing issues

Rust Version

rustc 1.55.0 (c8dfcfe04 2021-09-06)

Clap Version

v3.0.0-beta.4

Minimal reproducible code

fn main() {
    use clap::*;
    let app = App::new("myTest")
        .name("test")
        .author("Kevin K.")
        .about("tests stuff")
        .version("1.3")
        .arg(Arg::from("-f, --flag 'some flag'"))
        .arg(Arg::from("[arg] 'some pos arg'"))
        .arg(Arg::from("--option [opt] 'some option'"))
        .arg(Arg::from("-v, --verbose 'Extra info'").help_heading(Some("Debug")))
        .arg(Arg::from("-q, --quiet 'Less info'").help_heading(Some("Debug")));
    app.get_matches();
}

or

fn main() {
    use clap::*;
    let app = App::new("myTest")
        .name("test")
        .author("Kevin K.")
        .about("tests stuff")
        .version("1.3")
        .setting(AppSettings::UnifiedHelpMessage)
        .arg(Arg::from("-f, --flag 'some flag'"))
        .arg(Arg::from("[arg] 'some pos arg'"))
        .arg(Arg::from("--option [opt] 'some option'"))
        .arg(Arg::from("-v, --verbose 'Extra info'").help_heading(Some("Debug")))
        .arg(Arg::from("-q, --quiet 'Less info'").help_heading(Some("Debug")));
    app.get_matches();
}

Steps to reproduce the bug with the above code

cargo run -- --help

Actual Behaviour

❯ cargo run -- --help
   Compiling test-clap v0.1.0 (/home/epage/src/personal/test-clap)
    Finished dev [unoptimized + debuginfo] target(s) in 0.60s
     Running `target/debug/test-clap --help`
test 1.3

Kevin K.

tests stuff

USAGE:
    test-clap [FLAGS] [OPTIONS] [arg]

ARGS:
    <arg>    some pos arg

FLAGS:
    -f, --flag       some flag
    -h, --help       Print help information
    -V, --version    Print version information

OPTIONS:
        --option <opt>    some option

Debug:
    -q, --quiet      Less info
    -v, --verbose    Extra info

or

❯ cargo run -- --help
   Compiling test-clap v0.1.0 (/home/epage/src/personal/test-clap)
    Finished dev [unoptimized + debuginfo] target(s) in 0.63s
     Running `target/debug/test-clap --help`
test 1.3

Kevin K.

tests stuff

USAGE:
    test-clap [OPTIONS] [arg]

ARGS:
    <arg>    some pos arg

OPTIONS:
    -f, --flag            some flag
    -h, --help            Print help information
        --option <opt>    some option
    -q, --quiet           Less info
    -v, --verbose         Extra info
    -V, --version         Print version information

Expected Behaviour

Without having to override help_heading on every flag:

❯ cargo run -- --help
   Compiling test-clap v0.1.0 (/home/epage/src/personal/test-clap)
    Finished dev [unoptimized + debuginfo] target(s) in 0.60s
     Running `target/debug/test-clap --help`
test 1.3

Kevin K.

tests stuff

USAGE:
    test-clap [FLAGS] [OPTIONS] [arg]

ARGS:
    <arg>    some pos arg

OPTIONS:
    -f, --flag       some flag
    -h, --help       Print help information
    -V, --version    Print version information
        --option <opt>    some option

Debug:
    -q, --quiet      Less info
    -v, --verbose    Extra info

Additional Context

This is split off of #2807

We could fix this by respecting help_heading with UnifiedHelpMessage but it then seems like a misnomer because it is no longer unified.

Debug Output

No response

@epage epage added the C-bug Category: Updating dependencies label Oct 11, 2021
@epage epage added this to the 3.0 milestone Oct 11, 2021
@pksunkara pksunkara added A-help Area: documentation, including docs.rs, readme, examples, etc... C: usage strings labels Oct 11, 2021
@pksunkara pksunkara linked a pull request Oct 12, 2021 that will close this issue
@bors bors bot closed this as completed in #2867 Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-help Area: documentation, including docs.rs, readme, examples, etc... C-bug Category: Updating dependencies
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants