Commit graph

3442 commits

Author SHA1 Message Date
Benjamin Kästner
cde1a2d218 regex: Introduce convenience Cow-wrapper RegexRef
As previously discussed on [GitHub], this commit introduces a Cow-like
wrapper RegexRef to enable both `Regex` as well as `&Regex` as
arguments.

It also introduces a new module in the `build:arg` path to remove
clutter from the main module. For more information see #2073.

 [GitHub]: https://github.com/clap-rs/clap/pull/2073#issuecomment-674442310
2020-08-26 17:54:54 +02:00
Benjamin Kästner
8cb9a7d486 Add new "regex" feature
This commit introduces a new feature called `"regex"`. It adds a new
function `validator_regex` to `Arg` and was inspired by the discussion
in #1968. The name `validator_regex` was chosen instead of
`regex_validator` to make sure that the developer keeps in mind that
there may only be a single `Validator` on an `Arg`.

The feature can be used with YAML files, however there is no proper
pattern in `clap_app!` (yet).
2020-08-26 17:54:54 +02:00
bors[bot]
ebecccd009
Merge #2110
2110: Allow flatten with doc comments r=pksunkara a=CreepySkeleton



Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-08-26 07:13:34 +00:00
CreepySkeleton
a951958748 Allow flatten with doc comments 2020-08-25 20:20:56 +03:00
bors[bot]
8c47449bb5
Merge #2109
2109: fix: detect if space should be added before spec_vals r=CreepySkeleton a=knidarkness



Co-authored-by: knidarkness <knidarkness@gmail.com>
Co-authored-by: Sergey Dubovyk <knidarkness@gmail.com>
2020-08-25 13:35:22 +00:00
Sergey Dubovyk
d525be42c5
chore: use if instead of matching
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-08-25 11:07:19 +03:00
knidarkness
530b179776 fix: detect if space should be added before spec_vals 2020-08-25 10:41:08 +03:00
bors[bot]
ca368e5018
Merge #2104
2104: Basic centralized sanity test for all examples r=pksunkara a=mkantor



Co-authored-by: Matt Kantor <the.matt.kantor@gmail.com>
2020-08-24 18:44:43 +00:00
Matt Kantor
44ee8284c5 Exclude tests/examples.rs while checking coverage. 2020-08-24 10:23:49 -07:00
bors[bot]
29df5c2d16
Merge #2100 #2106
2100: Allow for nested subcommands with ZSH generation. r=pksunkara a=newAM



2106: Update the env var example for derive r=pksunkara a=rgreinho



Co-authored-by: Alex M <alexmgit@protonmail.com>
Co-authored-by: Rémy Greinhofer <remy.greinhofer@gmail.com>
2020-08-24 06:45:45 +00:00
bors[bot]
7853903052
Merge #2102
2102: Fix propagation r=pksunkara a=CreepySkeleton



Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-08-24 06:22:27 +00:00
Rémy Greinhofer
2a2cf81977 Update the env var example for derive
Updates the derive example handling environment variables to illustrate
the case where it contains a sensitive value which should not be
displayed on the help screen.

Closes https://github.com/clap-rs/clap/issues/2101
2020-08-23 18:18:25 -05:00
Matt Kantor
882f553c6a Test that --help works for all examples. 2020-08-23 11:23:43 -07:00
Matt Kantor
b41384d320 Make all examples compile & run without failure. 2020-08-23 11:23:43 -07:00
CreepySkeleton
1cd069090e Fix propagation 2020-08-23 20:56:29 +03:00
Alex M
60dfcf13b5 Allow for nested subcommands with ZSH generation. 2020-08-23 09:33:29 -07:00
bors[bot]
6a56a82629
Merge #2096
2096: Fix a few documentation typos r=CreepySkeleton a=drguildo



Co-authored-by: Simon Morgan <sjm@sjm.io>
2020-08-22 16:50:19 +00:00
Simon Morgan
2e973a2649 Fix a few documentation typos 2020-08-22 16:49:09 +01:00
bors[bot]
317a816857
Merge #2092
2092: Make caching in crate_authors! actually work r=pksunkara a=CreepySkeleton



Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-08-21 09:08:54 +00:00
CreepySkeleton
28ad25fe66 Ensure the lifetime is 'static 2020-08-21 08:41:50 +03:00
CreepySkeleton
fd1ee7872e Make caching in crate_authors! actually work 2020-08-21 08:21:21 +03:00
bors[bot]
ed3bb993c5
Merge #2087
2087: refactor: Avoid second traversal and unwrap r=pksunkara a=phimuemue



Co-authored-by: philipp <descpl@yahoo.de>
2020-08-21 03:56:53 +00:00
bors[bot]
977a44684c
Merge #2089
2089: Forbid all unsafe code. r=CreepySkeleton a=aspenluxxxy



Co-authored-by: aspen <luxx4x@protonmail.com>
2020-08-21 03:34:19 +00:00
aspen
96b7fd454b
Forbid all unsafe code. 2020-08-20 18:38:40 -04:00
bors[bot]
8454136126
Merge #2085
2085: Don't print spaces in long help r=pksunkara a=knightpp



Co-authored-by: Danil Kondratiev <knightpp@protonmail.com>
2020-08-20 17:42:58 +00:00
philipp
86dc14f5cd refactor: Avoid second traversal and unwrap 2020-08-20 19:32:53 +02:00
Danil Kondratiev
5b07c8a780
fix spaces in long help tests 2020-08-20 17:28:40 +03:00
Danil Kondratiev
4878f7b7b1
don't print spaces in long help 2020-08-20 17:25:36 +03:00
bors[bot]
be27f41f83
Merge #2082
2082: Do not capture args meant for libtest from the integration tests r=pksunkara a=mkantor



Co-authored-by: Matt Kantor <the.matt.kantor@gmail.com>
2020-08-18 21:02:34 +00:00
Matt Kantor
247d823314 Do not capture args meant for libtest from integration tests.
Using `App::get_matches` from the integration tests meant that any
CLI arguments passed to libtest would also be captured by clap, often
causing the tests to fail.

For example, running `cargo test --test help -- --nocapture` would
result in several failed tests, even though `cargo test --test help`
worked fine. This was very surprising/confusing.

This commit makes the tests no longer implicitly rely on the value of
`env::args_os()`, which means developers can now provide arguments to
libtest without failures.
2020-08-18 11:50:48 -07:00
bors[bot]
1e3d53fd1f
Merge #2081
2081: Polish doc comments for App r=CreepySkeleton a=mkantor



Co-authored-by: Matt Kantor <the.matt.kantor@gmail.com>
2020-08-17 20:56:13 +00:00
bors[bot]
025ec3c28b
Merge #2078
2078: Unify naming cheme r=pksunkara a=CreepySkeleton



Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-08-17 20:35:05 +00:00
Matt Kantor
f6e28c5ff0 Remove doc mention of no-longer-existing from_yaml method. 2020-08-17 12:54:24 -07:00
CreepySkeleton
0cc8663db3 Fix benches 2020-08-17 22:27:50 +03:00
Matt Kantor
494fddd06e Polish doc comments for App.
- Fix some links.
- Make the punctuation consistent.
- Correct some spelling/grammar mistakes.
2020-08-17 11:00:00 -07:00
bors[bot]
91cc8031a3
Merge #2075
2075: Issue 1464 r=pksunkara a=tomjw64



Co-authored-by: tomjw64 <tom.jw64@gmail.com>
2020-08-16 20:08:12 +00:00
tomjw64
27771ceeb7 Show arguments in conflict message in reverse order of input 2020-08-16 03:47:19 -05:00
tomjw64
97149e37f5 Remove underscore prefix for build_conflict_err_usage 2020-08-16 03:42:58 -05:00
tomjw64
35f761e699 Extract extra logic to _build_conflict_err_usage 2020-08-15 17:58:47 -05:00
CreepySkeleton
f4fb9db65c cargo fmt 2020-08-16 00:29:30 +03:00
CreepySkeleton
0b2eac4da7 Fix yaml support 2020-08-15 23:42:23 +03:00
CreepySkeleton
ce3171ace5 Arg::required_unless_all => required_unless_eq_all 2020-08-15 20:38:57 +03:00
CreepySkeleton
b12102c832 Arg::required_unless -> required_unless_present 2020-08-15 20:38:56 +03:00
CreepySkeleton
55dceca819 Improve documentation 2020-08-15 20:38:56 +03:00
CreepySkeleton
233af6e7a1 Arg::required_if => required_if_eq 2020-08-15 20:38:55 +03:00
CreepySkeleton
8b85c4ecea Arg::required_ifs => required_if_eq_any 2020-08-15 20:38:12 +03:00
CreepySkeleton
6b6b6035ed Arg::required_unless_one => required_unless_eq_any 2020-08-15 20:38:11 +03:00
tomjw64
481229fffd Remove stray print 2020-08-15 04:49:53 -05:00
tomjw64
826db05319 Add test for three argument conflict output 2020-08-15 04:43:12 -05:00
tomjw64
6602feb9e6 Also include required arguments in conflict output 2020-08-15 04:17:28 -05:00