Commit graph

3239 commits

Author SHA1 Message Date
Segev Finer
16b4f143ff fix(completions/zsh.rs): Don't pass -S to _arguments if Zsh is too old
If you do pass it than _arguments considers -C as a possible option in
the completions.
2018-01-14 07:13:27 +02:00
Segev Finer
1146f0da15 fix(completions/zsh.rs): Maybe fix completions with mixed positionals and subcommands
Optional positionals mixed with subcommands will still break this, since
I can't see how to tell which element of $line is the command than.
Mixing optional positionals with subcommands is a bit weird and awkward
though...
2018-01-14 07:13:23 +02:00
Segev Finer
e39aeab848 feat(completions/zsh.rs): Complete positional arguments properly
This changes the way we complete positionals to complete them using
_arguments, as should be done, instead of completing their uppercase name
as a string.

Currently I made it offer _files completion for all positional arguments.
This can be improved to complete actual possible values of the arguments
and only complete files if the argument truly takes them. But this will
require further changes in clap to actually have the required
functionality to get this information.
2018-01-14 07:12:14 +02:00
Will Murphy
dc0d8ba89c note-to-self comments 2018-01-13 16:32:45 -05:00
Matt Kraai
cc341243f3
Fix typos 2018-01-10 21:49:40 -08:00
Matt Kraai
b83f387b80
Fix typo 2018-01-10 21:01:21 -08:00
Segev Finer
0e185b922e fix(completions/zsh.zsh): Remove redundant code from output
Fixes #1142
2018-01-10 20:29:01 +02:00
William Murphy
1ab5c2d316
Merge branch 'master' into issue-1135 2018-01-10 06:28:58 -05:00
Kevin K
d78341f640
Merge pull request #1143 from kbknapp/trim-fat
Trim fat
2018-01-09 16:52:05 -05:00
Kevin K
3fef176543 docs: fixes typo in docs version 2018-01-09 12:07:19 -05:00
Kevin K
3e97085e58 chore: udpates html doc root 2018-01-09 12:02:35 -05:00
Kevin K
92caafaf51 chore: increase version 2018-01-09 11:08:47 -05:00
Kevin K
e1313a5a0f docs: updates contributors list 2018-01-09 11:04:56 -05:00
Kevin K
eb8d919e6f perf: further debloating by removing generics from error cases 2018-01-09 10:53:20 -05:00
Kevin K
7ac5a5af9f tests: cleans up certain test cases litle by little 2018-01-09 10:53:20 -05:00
Kevin K
03e413d717 perf: debloats clap by deduplicating logic and refactors
This commit removes heavy use of macros in certain functions which
drastically increased code size. Some of the macros could be turned
into functions, while others could be removed entirely.

Examples were removing arg_post_processing! which did things like
checked overrides, requirements, groups, etc. This would happen
after every argument was parsed. This macro also had several other
macros inside it, and would expand to several tens or hundreds of
lines of code.

Then add that due to borrowck and branch issues, this macro may be
included in multiple parts of a function. Unlike traditional functions
each of these uses expanded into TONS of code (just like agressive
inlining).

This commit primarily removes those arg_post_processing! calls and
breaks up the functionality into two types. The first must happen at
ever new argument (not new value, but new argument). This is pretty
cheap. The next type was moved to the end of parsing validation section
which is more expensive, but only happens once.

i.e. clap was validating each argument/value as it saw them, now it's
lazy and validates them all at once at the end. This MUCH more
efficient!
2018-01-09 10:53:20 -05:00
Kevin K
d26ab2b97c fix: fixes the ripgrep benchmark by adding a value to a flag that expects it 2018-01-09 10:53:20 -05:00
Kevin K
79c36396db tests: adds a check_output2 function to compare output to one of two possible solutions 2018-01-09 10:53:20 -05:00
Kevin K
6f25b2830a chore: adds .idea project folder to ignore list 2018-01-09 10:53:20 -05:00
Kevin K
28a55f28a2
Merge pull request #1141 from segevfiner/zsh-long-options-completion-fix
Fix completion of long option values in Zsh
2018-01-09 10:53:03 -05:00
Kevin K
eac4ca7898
Merge branch 'master' into zsh-long-options-completion-fix 2018-01-09 10:50:40 -05:00
Kevin K
f3cd07bf6a
Merge pull request #1138 from cldershem/fixDocLinks
docs: fixes broken links.
2018-01-09 10:49:28 -05:00
Kevin K
a23135a46a
Merge branch 'master' into fixDocLinks 2018-01-09 10:49:21 -05:00
Kevin K
666c5184d5
Merge pull request #1130 from fluffysquirrels/master
Fix for issue #1129: "Bug: Bash completion is broken when sub-commands have hyphens"
2018-01-09 10:48:24 -05:00
Segev Finer
46365cf8be fix(completions/zsh.rs): Fix completion of long option values
Long options take their argument either in the next word or after an
equals sign, but the Zsh completion specified that they take it either
in the same word with no separator or in the next word. See the
documentation of the Zsh _arguments function for more information.
2018-01-06 14:43:15 +02:00
Cameron Dershem
56e734b839 docs: fixes broken links.
Small correction to add a link to the source in the documentation, previously
it was a placeholder.

`rustdoc` does not appear to package assets with the docs, therefore
relative links looking for static files do not work. The links are
consistent enough on github that the static files can be directly linked
to on the master branch.
2017-12-27 00:00:06 -05:00
Will Murphy
63cc4bc6a7 Test for Issue 1135
It looks like required_unless_one has incorrect behavior if the
argument it applies to also has a short form.
2017-12-26 11:16:18 -05:00
Alex Helfet
ba7f1d18eb fix(bash completion): Change the bash completion script code generation to support hyphens. 2017-12-16 12:44:57 +00:00
Alex Helfet
b446a561ce tests(auto-completion): Update build_app_special_commands to include a sub-command with a hypen.
The tests pass but the bash completion script won't work yet.
2017-12-16 12:44:44 +00:00
Alex Helfet
09d1d4a568 tests(auto-completion): Normalise names in tests/completions.rs
From            -> To
===========================================
with_underscore -> (with_)?special_commands
WUS             -> SPECIAL_CMDS
special         -> special_help
SPECIAL         -> SPECIAL_HELP
2017-12-16 12:44:12 +00:00
Kevin K
e0f8479e0f
Merge pull request #1124 from Enet4/arg_enum_trailing_comma
Support trailing comma in arg_enum! fields
2017-12-07 16:45:28 -05:00
Eduardo Pinho
dde7fcf1ca Support trailing comma in arg_enum! fields 2017-12-07 00:53:55 +00:00
Kevin K
f38cb1dbb7
Merge pull request #1123 from rom1v/readme
Update default features in README
2017-12-05 09:44:57 -05:00
Xavier Bestel
cc6dfd2e54 Add doc on colored help (#40)
Added a note about `clap::App`'s _raw methods, and an example specifically about colored help text.
2017-12-05 15:20:17 +01:00
Romain Vimont
d954b3c734 Update default features in README
Since commit ac97edde90, feature
"wrap_help" is not enabled by default.

Update the README accordingly.
2017-12-05 13:55:57 +01:00
Kevin K
4442af96c6
Merge pull request #1122 from kbknapp/hide-env-vars
Hide env vars
2017-12-03 09:32:51 +09:00
Kevin K
e962f2cece
chore: increase version 2017-12-02 15:34:02 -05:00
Kevin K
ebc35bdc91
tests: adds tests for both showing and hiding the values inside ENV vars 2017-12-02 15:09:22 -05:00
Kevin K
fb41d062ee
api(Arg): adds Arg::hide_env_values(bool) which allows one to hide any current env values and display only the key in help messages 2017-12-02 15:09:21 -05:00
Kevin K
a652db08eb
Merge pull request #1121 from ignatenkobrain/patch-4
bump lazy_static to 1
2017-12-03 05:08:26 +09:00
Igor Gnatenko
f74e2dc45f
bump lazy_static to 1 2017-11-30 17:41:34 +01:00
Kevin K
bc9ab21934
Merge pull request #1119 from kbknapp/case-insensitive
Case insensitive
2017-11-29 00:35:31 +09:00
Kevin K
4e2881c3d2
docs: updates the contributors list 2017-11-28 08:57:04 -05:00
Kevin K
58a57d901b
chore: increase version 2017-11-28 08:57:04 -05:00
Kevin K
8c0cc5c386
style: rustfmt run 2017-11-28 08:57:04 -05:00
Kevin K
612ccaf14e
tests: adds tests for using possible_values with Arg::case_insensitive 2017-11-28 08:57:04 -05:00
Kevin K
80993357e1
api: Adds Arg::case_insensitive(bool) which allows matching Arg::possible_values without worrying about ASCII case
When used with `Arg::possible_values` it allows the argument value to pass validation even if
the case differs from that of the specified `possible_value`.

```rust
let m = App::new("pv")
    .arg(Arg::with_name("option")
        .long("--option")
        .takes_value(true)
        .possible_value("test123")
        .case_insensitive(true))
    .get_matches_from(vec![
        "pv", "--option", "TeSt123",
    ]);

assert!(m.value_of("option").unwrap().eq_ignore_ascii_case("test123"));
```

This setting also works when multiple values can be defined:

```rust
let m = App::new("pv")
    .arg(Arg::with_name("option")
        .short("-o")
        .long("--option")
        .takes_value(true)
        .possible_value("test123")
        .possible_value("test321")
        .multiple(true)
        .case_insensitive(true))
    .get_matches_from(vec![
        "pv", "--option", "TeSt123", "teST123", "tESt321"
    ]);

let matched_vals = m.values_of("option").unwrap().collect::<Vec<_>>();
assert_eq!(&*matched_vals, &["TeSt123", "teST123", "tESt321"]);
```

Closes #1118
2017-11-28 08:57:04 -05:00
Kevin K
e53c33d6b9
Merge pull request #1117 from kbknapp/clap_derive
Clap derive
2017-11-28 20:16:01 +09:00
Kevin K
ce6ca492c7
docs: changes the demo version to 2.28 to stay in sync 2017-11-28 04:38:37 -05:00
Kevin K
9ef3d82bd0
chore: increase version 2017-11-27 10:28:28 -05:00