Skip to content
This repository has been archived by the owner on Jan 1, 2022. It is now read-only.

textwrap is confused by ColoredHelp #93

Open
epage opened this issue Dec 6, 2021 · 5 comments
Open

textwrap is confused by ColoredHelp #93

epage opened this issue Dec 6, 2021 · 5 comments

Comments

@epage
Copy link
Owner

epage commented Dec 6, 2021

Issue by vincentdephily
Friday Apr 13, 2018 at 09:25 GMT
Originally opened as clap-rs/clap#1246


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();
@epage epage added this to the 3.1 milestone Dec 6, 2021
@epage
Copy link
Owner Author

epage commented Dec 6, 2021

Comment by kbknapp
Tuesday May 22, 2018 at 18:25 GMT


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 😉

@epage
Copy link
Owner Author

epage commented Dec 6, 2021

Comment by mgeisler
Tuesday May 22, 2018 at 19:26 GMT


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.

@epage
Copy link
Owner Author

epage commented Dec 6, 2021

Comment by pksunkara
Tuesday Apr 14, 2020 at 22:06 GMT


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.

@epage
Copy link
Owner Author

epage commented Dec 6, 2021

Comment by CreepySkeleton
Tuesday Jun 30, 2020 at 13:07 GMT


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

@epage
Copy link
Owner Author

epage commented Dec 6, 2021

Comment by pksunkara
Tuesday Jun 30, 2020 at 23:08 GMT


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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant