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

Missing trailing newline on error with disabled help flag and subcommand #2787

Closed
2 tasks done
jonathanmorley opened this issue Sep 24, 2021 · 1 comment
Closed
2 tasks done
Labels
A-help Area: documentation, including docs.rs, readme, examples, etc... C-bug Category: Updating dependencies 💸 $5

Comments

@jonathanmorley
Copy link
Contributor

Please complete the following tasks

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

Rust Version

1.54.0

Clap Version

master

Minimal reproducible code

fn main() {
    let app = App::new("foo")
        .subcommand(App::new("sub"))
        .setting(AppSettings::DisableHelpFlag)
        .setting(AppSettings::DisableHelpSubcommand);
}

Steps to reproduce the bug with the above code

cargo run -- help

Actual Behaviour

The help message does not contain a trailing newline

Expected Behaviour

The help message should contain a trailing newline

Additional Context

https://github.com/clap-rs/clap/pull/2786/files#r715734272

Debug Output

No response

@jonathanmorley jonathanmorley added the C-bug Category: Updating dependencies label Sep 24, 2021
@pksunkara pksunkara linked a pull request Sep 24, 2021 that will close this issue
@pksunkara pksunkara added 💸 $5 A-help Area: documentation, including docs.rs, readme, examples, etc... D: easy labels Sep 24, 2021
@epage epage changed the title Missing trailing newline on help with disabled flag and subcommand Missing trailing newline on error with disabled flag and subcommand Dec 13, 2021
@epage epage changed the title Missing trailing newline on error with disabled flag and subcommand Missing trailing newline on error with disabled help flag and subcommand Dec 13, 2021
@epage
Copy link
Member

epage commented Dec 13, 2021

The problem is in src/parser/error.rs. Instead of the code focusing only on leading or trailing newlines for each section, it mixes them. usage and try_help use leading newlines but try_help also uses a trailing newline, if its used.

As a short term solution, we could add an else clause in try_help that adds a trailing newline. Ideally, we'd better organize this so it was more predictable of what happens.

epage added a commit to epage/clap that referenced this issue Dec 13, 2021
Found this when auditing for cases related to clap-rs#2787.
epage added a commit to epage/clap that referenced this issue Dec 13, 2021
Found this when auditing for cases related to clap-rs#2787.
@epage epage closed this as completed in 2eb69de Dec 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 💸 $5
Projects
None yet
Development

No branches or pull requests

3 participants