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

The header for my examples are not colored like the others #3108

Closed
2 tasks done
epage opened this issue Dec 9, 2021 · 6 comments · Fixed by #4765
Closed
2 tasks done

The header for my examples are not colored like the others #3108

epage opened this issue Dec 9, 2021 · 6 comments · Fixed by #4765
Labels
A-help Area: documentation, including docs.rs, readme, examples, etc... C-bug Category: Updating dependencies S-blocked Status: Blocked on something else such as an RFC or other implementation work.
Milestone

Comments

@epage
Copy link
Member

epage commented Dec 9, 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-rc.0

Minimal reproducible code

use clap::Parser;

const AFTER_TEST: &str = "
Examples:
    foo --hello
";

#[derive(Parser, Debug)]
#[clap(author, about)]
#[clap(after_help = AFTER_TEST)]
struct Opt {}

fn main() {
    let opt = Opt::parse();
    dbg!(opt);
}

Steps to reproduce the bug with the above code

cargo run -- --help

Actual Behaviour

Examples isn't colored:

test-clap 

Me

From Cargo.toml

USAGE:
    test-clap

OPTIONS:
    -h, --help    Print help information


Examples:
    foo --hello

Expected Behaviour

Examples is colored

Additional Context

Inspired by help2man in #3096.

Including example commands is a really useful pattern and now that we color by default, doing this stands out.

Something like #1790 could help. Alternatively, we could have after_help take a section name, maybe as an Option. Like with override_usage, we'd probably want the indentation to be user-defined.

Debug Output

No response

@epage epage added C-bug Category: Updating dependencies A-help Area: documentation, including docs.rs, readme, examples, etc... labels Dec 9, 2021
@pksunkara
Copy link
Member

What's the reason behind categorising this as bug? I would think this would be more of an enhancement, right?

@epage
Copy link
Member Author

epage commented Dec 9, 2021

Sometimes, its an arbitrary distinction. From a users perspective, its a bug in the application

@epage
Copy link
Member Author

epage commented Dec 9, 2021

#1433 has a similar use case for help templates and has a different proposed solution.

@epage epage added the S-waiting-on-design Status: Waiting on user-facing design to be resolved before implementing label Dec 13, 2021
@epage epage mentioned this issue Dec 14, 2021
4 tasks
@epage
Copy link
Member Author

epage commented Jan 20, 2022

#2389 might be the path to us exposing some formatting control.

@gaborcsardi
Copy link

Yet another way to solve this relatively painlessly is to allow calling before_help() and after_help() (and maybe about()) multiple times, each time possibly with a heading. The individual calls would be concatenated to create the final output.

@epage
Copy link
Member Author

epage commented Aug 18, 2022

My plan is for the API to accept ANSI colored strings. When we output, we use a special stdout/stderr that adapt the ANSI color codes to the capabilities of the terminal.

Blocked on https://github.com/epage/anstyle/issues/5

@epage epage added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-design Status: Waiting on user-facing design to be resolved before implementing labels Aug 18, 2022
@epage epage added this to the 4.x milestone Aug 30, 2022
ramnivas added a commit to exograph/exograph that referenced this issue Oct 26, 2022
This upgrade removes the colorization of the output of the `--help` command. We will track clap-rs/clap#3108 to restore it in the future.
ramnivas added a commit to exograph/exograph that referenced this issue Oct 26, 2022
This upgrade removes the colorization of the output of the `--help` command. We will track clap-rs/clap#3108 to restore it in the future.
epage added a commit to epage/clap that referenced this issue Mar 17, 2023
epage added a commit to epage/clap that referenced this issue Mar 17, 2023
epage added a commit to epage/clap that referenced this issue Mar 18, 2023
epage added a commit to epage/clap that referenced this issue Mar 18, 2023
epage added a commit to epage/clap that referenced this issue Mar 18, 2023
epage added a commit to epage/clap that referenced this issue Mar 18, 2023
epage added a commit to epage/clap that referenced this issue Mar 28, 2023
shadaj pushed a commit to exograph/exograph that referenced this issue Apr 20, 2023
This upgrade removes the colorization of the output of the `--help` command. We will track clap-rs/clap#3108 to restore it in the future.
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 S-blocked Status: Blocked on something else such as an RFC or other implementation work.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants