Martin Geisler
b93870c10a
feat: use textwrap crate for wrapping help texts
...
The textwrap crate uses a simpler linear-time algorithm for wrapping
the text. The current algorithm in wrap_help uses several O(n) calls
to String::insert and String::remove, which makes it potentially
quadratic in complexity.
Comparing the 05_ripgrep benchmark at commits textwrap~2 and textwrap
gives this result on my machine:
name before ns/iter after ns/iter diff ns/iter diff %
build_app_long 22,101 21,099 -1,002 -4.53%
build_app_short 22,138 21,205 -933 -4.21%
build_help_long 514,265 284,467 -229,798 -44.68%
build_help_short 85,720 85,693 -27 -0.03%
parse_clean 23,471 22,859 -612 -2.61%
parse_complex 29,535 28,919 -616 -2.09%
parse_lots 422,815 414,577 -8,238 -1.95%
As part of this commit, the wrapping_newline_chars test was updated.
The old algorithm had a subtle bug where it would break lines too
early. That is, it wrapped the text like
ARGS:
<mode> x, max, maximum 20 characters, contains
symbols.
l, long Copy-friendly,
14 characters, contains symbols.
m, med, medium Copy-friendly, 8
characters, contains symbols.";
when it should really have wrapped it like
ARGS:
<mode> x, max, maximum 20 characters, contains
symbols.
l, long Copy-friendly, 14
characters, contains symbols.
m, med, medium Copy-friendly, 8
characters, contains symbols.";
Notice how the word "14" was incorrectly moved to the next line. There
is clearly room for the word on the line with the "l, long" option
since there is room for "contains" just above it.
I'm not sure why this is, but the algorithm in textwrap handles this
case correctly.
2017-05-29 17:02:57 -04:00
Martin Geisler
13653042c2
tests: add wrap_help test with significant whitepace
...
This adds a test for the issue #617 about keeping whitespace intact in
manually aligned text.
2017-05-29 17:02:57 -04:00
Martin Geisler
918283d645
tests: benchmark building ripgrep help text
...
The ripgrep benchmarks work with lots of options and have really long
help texts. This makes them a good fit for judging the overall time it
takes to construct and format the help text.
2017-05-29 17:02:57 -04:00
Kevin K
821929b51b
docs(README.md): added a warning about using ~ deps
...
Closes #964
2017-05-29 13:10:55 -04:00
nate
d06f819f42
remove public from Colorizer properties and use ColorizerOption instead.
2017-05-29 13:04:47 -04:00
nate
4293013c26
clean up. fix lint and formatting.
2017-05-29 13:04:47 -04:00
nate
53e3d833f1
refactor to add ColorizeOption
2017-05-29 13:04:47 -04:00
nate
f400fa6e7f
refactor color macro. refactor Colorizer to have ColorizerOption.
2017-05-29 13:04:47 -04:00
nate
f915f9ce42
add ColorizeOption and add function "new" for Colorizer
...
it has logic where checking tty is valid and if TERM is dumb when coloring
a message.
2017-05-29 13:04:47 -04:00
nate
3185511f3b
when TERM=dumb
, the output is colorless #847
...
comply to
2017-05-29 13:04:47 -04:00
Kevin K
45092b9def
chore: disables mention-bots finding reviewers and pinging tons of people
2017-05-29 13:00:27 -04:00
Jacob Mischka
53c1ffe87f
fix: Change who's
-> whose
2017-05-29 12:58:18 -04:00
Martin Geisler
dd4c41e237
cargo: restrict unicode-segmentation to ~1.1.0
...
The newly released version 1.2.0 of unicode-segmentation adds code
that use the "?" operator, which in turn requires Rust 1.13.0.
However, clap currently still works with Rust 1.11.0 and this caused
build failures:
https://travis-ci.org/kbknapp/clap-rs/jobs/235010822
The changes since 1.1.0 seem to be related cursors/iterators and I
think clap can work fine without them.
2017-05-28 19:37:53 -04:00
Kevin K
2923515a0a
chore: increase version'
2017-05-16 07:23:22 -04:00
Kevin K
826048cb3c
docs(clap_app!): adds using the @group specifier to the macro docs
...
Closes #932
2017-05-16 07:23:22 -04:00
Kevin K
17c97ee8c5
tests: adds a test where a non-existing arg is added to a group to ensure a failed debug assertion
2017-05-16 07:23:22 -04:00
Kevin K
7ad123e2c0
fix: adds a debug assertion to ensure all args added to groups actually exist
...
Closes #917
2017-05-16 07:23:22 -04:00
Kevin K
cbea3d5acf
docs(App::template): adds details about the necessity to use AppSettings::UnifiedHelpMessage when using {unified} tags in the help template
...
Closes #949
2017-05-16 07:23:22 -04:00
Kevin K
f9b0d65783
docs(Arg::allow_hyphen_values): updates the docs to include warnings for allow_hyphen_values and multiple(true) used together
2017-05-16 07:23:22 -04:00
Kevin K
ab2f4c9e56
fix: fixes a bug where args that allow values to start with a hyphen couldnt contain a double hyphen -- as a value
...
Closes #960
2017-05-16 07:23:22 -04:00
Kevin K
5209b61192
tests: adds tests for using double hyphen -- as a value
2017-05-16 07:23:22 -04:00
Guanqun Lu
34a7436dd3
trivial typo fixes
2017-05-11 20:52:35 -04:00
golem131
60cc838a42
Fix tests
2017-05-11 20:45:15 -04:00
golem131
3deb1943e0
Dependency update
2017-05-11 20:45:15 -04:00
Kevin K
54c16836de
fix: fixes a bug where positional argument help text is misaligned
2017-05-10 20:29:54 -04:00
Kevin K
c556b39fd0
chore: increase version
2017-05-07 10:46:03 -04:00
Kevin K
9f9364b1d8
fix: fixes a bug where args with last(true) and required(true) set were not being printed in the usage string
...
Closes #944
2017-05-07 10:46:03 -04:00
Kevin K
3223f21a90
tests: adds tests to last(true) args are printed in the usage even when required
2017-05-07 10:46:03 -04:00
Kevin K
8713da2372
fix: fixes a bug that was printing the arg name, instead of value name when Arg::last(true) was used
...
Closes #940
2017-05-07 10:46:03 -04:00
Kevin K
3ed0f70c6e
tests: adds tests to ensure positional values value name are used in usage strings instead of names when defined
2017-05-07 10:46:03 -04:00
Kevin K
fedb46b5b1
fix: fixes a bug where flags were parsed as flags AND positional values when specific combinations of settings were used
...
This commit fixes a bug where using `AppSettings::AllowHyphenValues`
would cause flags with longs be *also* parsed as positional values.
Closes #946
2017-05-07 10:46:03 -04:00
Kevin K
52d110df81
docs(AllowHyphenValues): updates the docs to remove old limitations that no longer apply
2017-05-07 10:46:03 -04:00
Kevin K
4048072021
tests: adds tests to ensure flags not incorrectly parsed as positionals
2017-05-07 10:46:03 -04:00
Kevin K
bd4dbb4214
chore: increase version
2017-05-05 18:59:32 +02:00
Homu
b7d874be87
Auto merge of #941 - nuew:default_value_os, r=kbknapp
...
api(Arg): add `default_value_os`
Also add related tests, and reframe `default_value` in terms of
`defualt_value_os`.
This resolves #849 .
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg " height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/kbknapp/clap-rs/941 )
<!-- Reviewable:end -->
2017-05-05 09:57:29 +09:00
Nuew
d5ef895541
api(Arg): add default_value_os
...
Also add related tests, and reframe `default_value` in terms of
`defualt_value_os`.
2017-04-24 15:49:59 -04:00
Homu
dd485ebc6a
Auto merge of #939 - golddranks:master, r=kbknapp
...
api(arg_matches.rs): Added a Default implementation for Values and OsValues iterators.
Fixes https://github.com/kbknapp/clap-rs/issues/935 .
The iterators terminate with `None` on the first call to `.next()`.
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg " height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/kbknapp/clap-rs/939 )
<!-- Reviewable:end -->
2017-04-24 09:54:17 +09:00
Pyry Kontio
0a4384e350
api(arg_matches.rs): Added a Default implementation for Values and OsValues iterators.
2017-04-23 23:49:20 +09:00
Homu
448ba6a6f0
Auto merge of #938 - Kalwyn:master, r=kbknapp
...
docs(README.md): fix some typos
This is the first time i make a pull request. I hope i have done things right.
I love clap-rs very much. Thank you for your hard work.
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg " height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/kbknapp/clap-rs/938 )
<!-- Reviewable:end -->
2017-04-23 09:48:45 +09:00
Kalwyn Solork
fa34deac07
docs(README.md): fix some typos
2017-04-22 23:11:53 +02:00
Homu
de1fea4c66
Auto merge of #934 - kbknapp:issue-931, r=kbknapp
...
Issue 931
<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg " height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/kbknapp/clap-rs/934 )
<!-- Reviewable:end -->
2017-04-19 21:35:36 +09:00
Kevin K
2572150558
chore: increase version
2017-04-18 23:19:24 -04:00
Kevin K
85b0e1cc4b
imp(PowerShell Completions): massively dedups subcommand names in the generate script to make smaller scripts that are still functionally equiv
2017-04-18 23:17:05 -04:00
Kevin K
a8bce55837
fix(PowerShell Completions): fixes a bug where powershells completions cant be used if no subcommands are defined
...
Closes #931
2017-04-18 23:01:20 -04:00
Homu
3f44dd4b91
Auto merge of #926 - kbknapp:v2.23.2, r=kbknapp
...
V2.23.2
<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg " height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/kbknapp/clap-rs/926 )
<!-- Reviewable:end -->
2017-04-10 09:43:49 +09:00
Kevin K
f842e8fcec
chore: increase version
2017-04-09 14:40:43 -04:00
Kevin K
e05100b73d
imp: bumps term_size to take advantage of better terminal dimension handling
2017-04-09 14:39:38 -04:00
Homu
6cbc161a09
Auto merge of #925 - mdaffin:doc-typo-fix, r=kbknapp
...
docs: Fix a typo the minimum rust version required
<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg " height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/kbknapp/clap-rs/925 )
<!-- Reviewable:end -->
2017-04-07 23:56:08 +09:00
Michael Daffin
71dabba3ea
docs: Fix a typo the minimum rust version required
2017-04-07 10:02:00 +01:00
Kevin K
6095f239ba
chore: increase version
2017-04-05 10:59:55 -04:00