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

Extra blank lines when the argument name is long enough in --help #4631

Closed
2 tasks done
madchicken opened this issue Jan 12, 2023 · 2 comments
Closed
2 tasks done

Extra blank lines when the argument name is long enough in --help #4631

madchicken opened this issue Jan 12, 2023 · 2 comments
Labels
A-help Area: documentation, including docs.rs, readme, examples, etc... C-bug Category: Updating dependencies

Comments

@madchicken
Copy link

madchicken commented Jan 12, 2023

Please complete the following tasks

Rust Version

rustc 1.64.0 (a55dd71d5 2022-09-19)

Clap Version

clap = { version = "3.2.23", features = ["derive"] }

Minimal reproducible code

use clap::{Parser};

#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
pub struct Config {
    /// Your username
    #[clap(short, long, value_parser)]
    username: String,
    /// Your password
    #[clap(short, long, value_parser)]
    password: String,
    /// Server URI
    #[clap(long, value_parser, default_value = "http://localhost:8581")]
    uri: String,
    /// Authorization keys file. Default to authorization-keys.yml in the current working directory.
    #[clap(long, value_parser, default_value = "authorization-keys.yml")]
    keyfile_path: String,
    /// Metrics webserver port (service /metrics for Prometheus scraper)
    #[clap(long, value_parser, default_value = "9123")]
    port: u16,
}


fn main() {
    let _config = Config::parse();
}

Steps to reproduce the bug with the above code

Run the command:

cargo run -- --help

Actual Behaviour

mycli 0.1.0

USAGE:
    mycli [OPTIONS] --username <USERNAME> --password <PASSWORD>

OPTIONS:
    -h, --help
            Print help information

        --keyfile-path <KEYFILE_PATH>
            Authorization keys file. Default to authorization-keys.yml in the current working
            directory [default: authorization-keys.yml]

    -p, --password <PASSWORD>
            Your password

        --port <PORT>
            Metrics webserver port (service /metrics for Prometheus scraper) [default: 9123]

    -u, --username <USERNAME>
            Your username

        --uri <URI>
            Server URI [default: http://localhost:8581]

    -V, --version
            Print version information

Expected Behaviour

mycli 0.1.0

USAGE:
    mycli [OPTIONS] --username <USERNAME> --password <PASSWORD>

OPTIONS:
    -h, --help                         Print help information
        --keyfile-path <KEYFILEPATH>    Authorization keys file. Default to authorization-keys.yml in
                                       the current working directory [default:
                                       authorization-keys.yml]
    -p, --password <PASSWORD>          Your password
        --port <PORT>                  Metrics webserver port (service /metrics for Prometheus
                                       scraper) [default: 9123]
    -u, --username <USERNAME>          Your username
        --uri <URI>                    Server URI [default: http://localhost:8581]
    -V, --version                      Print version information

Additional Context

The output shows extra new lines.
By changing the name of the parameter keyfile_path to keyfilepath the issue goes away.

Debug Output

No response

@madchicken madchicken added the C-bug Category: Updating dependencies label Jan 12, 2023
@epage
Copy link
Member

epage commented Jan 12, 2023

While #3300 is for -h, a lot of the conversation is the same. We can leave this open if you want, to track any --help specific aspects.

See also #4550

@epage epage added the A-help Area: documentation, including docs.rs, readme, examples, etc... label Jan 12, 2023
@epage epage changed the title Bad formatting depending on the name of a parameter Extra blank lines when the argument name is long enough in --help Jan 12, 2023
@madchicken
Copy link
Author

It's fine for me to mark this as a duplicate. And sorry for this, I searched through the open issues but I could not find my problem (my bad)

@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Jan 12, 2023
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

No branches or pull requests

2 participants