Commit graph

2204 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
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
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
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
Kevin K
6f4c341241
api: Adds the traits to be used with the clap-derive crate to be able to use Custom Derive
Currently to use these traits clap must be built with the `unstable` feature. This does not
require a nightly compiler. These traits and APIs may change without warning (hence the `unstable`
feature flag). Once they have been stablelized and the `clap-derive` crate is released the
`unstable` feature flag will no longer be required.
2017-11-27 09:55:52 -05:00
Kevin K
8a26ff07b0
style: changes the display of the env var from 'env:VAR: value' to 'env: VAR=value' 2017-11-27 09:55:43 -05:00
Kevin K
4740cde404
Merge pull request #1114 from ignatenkobrain/bash-comp
use .bash as extension for bash completions
2017-11-24 19:32:55 -05:00
Igor Gnatenko
bfcf5dd076 use .bash as extension for bash completions
* bash-completions have code to use only `foo`, `foo.bash` and `_foo`
files for completion
* /usr is proper place for system-wide stuff rather than /etc

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-11-23 18:48:36 +01:00
Kevin K
c2c2a56a30
Merge pull request #1113 from kbknapp/issue-1112
Issue 1112
2017-11-22 07:19:33 -05:00
Kevin K
89c0ed0328
tests: adds tests to guard against --help and -h being overridable 2017-11-22 04:11:28 -05:00
Kevin K
a283d69fc0
fix: Fixes a regression where --help couldn't be overridden
Closes #1112
2017-11-22 04:11:28 -05:00