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

Open
vincentdephily opened this Issue Apr 13, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@vincentdephily

vincentdephily commented Apr 13, 2018

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

This comment has been minimized.

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

This comment has been minimized.

Contributor

mgeisler commented May 22, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment