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

Subcommand flags are separated by spaces while argument flags use commas #4232

Closed
2 tasks done
Trivernis opened this issue Sep 19, 2022 · 1 comment · Fixed by #4235
Closed
2 tasks done

Subcommand flags are separated by spaces while argument flags use commas #4232

Trivernis opened this issue Sep 19, 2022 · 1 comment · Fixed by #4235
Labels
C-bug Category: Updating dependencies

Comments

@Trivernis
Copy link

Trivernis commented Sep 19, 2022

Please complete the following tasks

Rust Version

1.63.0

Clap Version

3.2.22

Minimal reproducible code

use clap::{Parser, Subcommand};

#[derive(Parser)]
#[clap()]
struct Args {
    #[clap(short)]
    arg: String,

    #[clap(subcommand)]
    subcommand: Command,
}

#[derive(Subcommand)]
enum Command {
    #[clap(name = "test", short_flag = 't', long_flag = "test")]
    Test,
}

fn main() {
    let _args = Args::parse();
}

Steps to reproduce the bug with the above code

cargo run

Actual Behaviour

The help output is

clap-test 

USAGE:
    clap-test -a <ARG> <SUBCOMMAND>

OPTIONS:
    -a <ARG>        
    -h, --help      Print help information

SUBCOMMANDS:
    help              Print this message or the help of the given subcommand(s)
    test -t --test    

Which separates the options-flags by comma while the subcommand flags are just separated by space. This behaviour is inconsistent. I personally would prefer to use comma for separation in both cases as it is easier to understand.

Expected Behaviour

The help output should look like this:

clap-test 

USAGE:
    clap-test -a <ARG> <SUBCOMMAND>

OPTIONS:
    -a <ARG>        
    -h, --help      Print help information

SUBCOMMANDS:
    help              Print this message or the help of the given subcommand(s)
    test, -t, --test    

Additional Context

This issue relates to crystal-linux/amethyst#64

Debug Output

No response

@Trivernis Trivernis added the C-bug Category: Updating dependencies label Sep 19, 2022
epage added a commit to epage/clap that referenced this issue Sep 19, 2022
@epage
Copy link
Member

epage commented Sep 19, 2022

This was fixed in master which corresponds with the upcoming v4.0.0

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

Successfully merging a pull request may close this issue.

2 participants