• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kbknapp / clap-rs / 3094
89%
master: 94%

Build:
Build:
LAST BUILD BRANCH: issues-839,840
DEFAULT BRANCH: master
Ran 31 Jan 2017 12:50AM UTC
Jobs 4
Files 61
Run time 33min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
3094

push

travis-ci

homu
Auto merge of #832 - mgeisler:fix-wrapping-bugs, r=kbknapp

Fix wrapping bugs

I've been working towards integrating my [textwrap][1] crate and along the way, I found some small problems in the existing `wrap_help` function in clap. I basically added new code that calls both `textwrap::fill` and `wrap_help` and panicked on any difference:
```
fn wrap_help(help: &mut String, longest_w: usize, avail_chars: usize) {
    let input = help.clone();
    let mut old = help.clone();
    old_wrap_help(&mut old, longest_w, avail_chars);

    let mut wrapped = String::with_capacity(help.len());
    for (i, line) in help.lines().enumerate() {
        if i > 0 {
            wrapped.push('\n');
        }
        wrapped.push_str(&textwrap::fill(line, avail_chars));
    }

    // TODO: move up, This keeps old behavior of not wrapping at all
    // if one of the words would overflow the line
    if longest_w < avail_chars {
        *help = wrapped;
    }

    if *old != *help {
        println!("********************************");
        println!("longest_w: {}, avail_chars: {}", longest_w, avail_chars);
        println!("help: {:3} bytes: {:?}", input.len(), input);
        println!("old:  {:3} bytes: {:?}", old.len(), old);
        println!("new:  {:3} bytes: {:?}", help.len(), help);
        println!("********************************");
        panic!("bad wrap");
    }
}

fn old_wrap_help(help: &mut String, longest_w: usize, avail_chars: usize) {
    // ... as before
```

This PR fixes two small problems discovered this way, one of which became #828.

[1]: https://crates.io/crates/textwrap

7647 of 8585 relevant lines covered (89.07%)

3.21 hits per line

Jobs
ID Job ID Ran Files Coverage
1 3094.1 31 Jan 2017 12:50AM UTC 0
88.97
Travis Job 3094.1
2 3094.2 31 Jan 2017 12:52AM UTC 0
91.86
Travis Job 3094.2
4 3094.4 31 Jan 2017 12:51AM UTC 0
91.19
Travis Job 3094.4
5 3094.5 31 Jan 2017 01:23AM UTC 0
88.97
Travis Job 3094.5
Source Files on build 3094
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #3094
  • e9e01e13 on github
  • Prev Build on auto (#3084)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc