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

textwrap is confused by ColoredHelp #1246

Closed
vincentdephily opened this issue Apr 13, 2018 · 7 comments
Closed

textwrap is confused by ColoredHelp #1246

vincentdephily opened this issue Apr 13, 2018 · 7 comments
Labels
A-help Area: documentation, including docs.rs, readme, examples, etc... C-bug Category: Updating dependencies

Comments

@vincentdephily
Copy link

This presumably depends on #836

Rust Version

1.25.0

Affected Version of clap

2.31.2

Expected Behavior Summary

Displaying colored help should use the available term_width.

    -f <foo>                        Many colored values make this obvious [default: a]  [possible values: a, b, c, d, e,
                                    f, g, h, i, j]

Actual Behavior Summary

The escape sequences make the String look long to the text wrapper, but not to the user, and the newline arrive long before the visible term_width.

    -f <foo>                        Many colored values make this obvious [default: a]  [possible values:
                                    a, b, c, d, e, f, g, h,
                                    i, j]

Steps to Reproduce the issue

Take this App definition and run it either normally (colored) or piped to cat (non-colored).

    let args = app_from_crate!()
        .global_setting(AppSettings::ColoredHelp)
        .arg(Arg::with_name("foo")
             .help("Many colored values make this obvious")
             .short("f")
             .takes_value(true) 
             .possible_values(&["a","b","c","d","e","f","g","h","i","j"])
             .default_value("a"))
     .get_matches();
@kbknapp
Copy link
Member

kbknapp commented May 22, 2018

Sorry for the long wait, I've been out with my day job.

I looks like the unprinted color codes are what's confusing it.

@mgeisler this looks like it might be on your end 😉

@mgeisler
Copy link
Contributor

Hi guys, yeah, that is something textwrap should be able to handle better! Thanks for the great bug report, I've added an issue for it in my tracker: mgeisler/textwrap#140.

@pksunkara pksunkara added this to the 3.0 milestone Apr 9, 2020
@pksunkara pksunkara self-assigned this Apr 11, 2020
@pksunkara pksunkara modified the milestones: 3.0, 3.1 Apr 11, 2020
@pksunkara pksunkara removed their assignment Apr 11, 2020
@pksunkara pksunkara added this to the 3.1 milestone Apr 14, 2020
@pksunkara
Copy link
Member

This is fixed in #1824 because I removed the colors for arg metadata. Re-adding them back will be addressed in #1456. And that should address this properly. Keeping this open until then.

@pksunkara pksunkara added A-help Area: documentation, including docs.rs, readme, examples, etc... C: colorizing and removed C: upstream crate / dep labels Apr 14, 2020
@CreepySkeleton
Copy link
Contributor

The linked textwrap issue has been closed, so this is probably fixed. We would need to check again nonetheless.

@pksunkara
Copy link
Member

I removed the colors from being sent to textwrap. That still doesn't solve this issue because we are now not coloring the possible/default values. Let's keep this open until that is fixed.

@epage epage added C-bug Category: Updating dependencies and removed C: colorizing labels Dec 8, 2021
@epage epage removed this from the 3.1 milestone Dec 8, 2021
@epage
Copy link
Member

epage commented Dec 9, 2021

So it sounds like we've implemented a hack (remove coloring) and textwrap has a permanent fix even if we undo the hack.

@pksunkara what would be the reason for keeping this open?

@pksunkara
Copy link
Member

I think I wanted this open to give more context for #1456.

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

6 participants