Commit graph

669 commits

Author SHA1 Message Date
Ed Page
3c937dc76a fix: Allow tests without cargo feature 2021-11-17 14:27:26 -06:00
Ed Page
4479282b11 style: Address warnings 2021-11-17 14:23:32 -06:00
bors[bot]
ca3e14ca2d
Merge #3014
3014: fix(app): Propogate color  r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-11-13 10:43:42 +00:00
Pavan Kumar Sunkara
69957c4ddd Revert "Revert "Fixes arg having required_unless on default values""
This reverts commit 6e85fb3ae0.
2021-11-11 21:33:50 +00:00
Pavan Kumar Sunkara
bdb1d324a5 Revert "Revert "Fixes arg having required_if on default values""
This reverts commit 8818327b25.
2021-11-11 21:33:50 +00:00
Pavan Kumar Sunkara
b102da0cd2 Revert "Revert "Fixes arg and group with default value having requires""
This reverts commit bd8c36cf04.
2021-11-11 21:33:50 +00:00
Pavan Kumar Sunkara
72429be14e Revert "Revert "Fixes group conflicting if two args with default values""
This reverts commit 4e370bb093.
2021-11-11 21:33:50 +00:00
Pavan Kumar Sunkara
0b7def675b Revert "Revert "Fixes arg conflicting with group whose arg has default value""
This reverts commit 706085d9c5.
2021-11-11 21:33:50 +00:00
Pavan Kumar Sunkara
b86aa631be Revert "Revert "Fixes group conflicting with arg which has default value""
This reverts commit 736cb28dd0.
2021-11-11 21:33:50 +00:00
Ed Page
a2c3b14bb0 fix(app): Propogate color
In #2851, we moved color from an AppSetting to function (with some
tweaks in #2907).  When doing this, we documented `App::color` to be
equivalent of `App::global_settings(Color...)` but never actually
propagated it.

We are now propagating it.  A test is added to ensure that no matter
how we store the color choice, we continue to propagate it.  This
required exposing `App::get_color`.
2021-11-11 11:39:21 -06:00
Matthew Fisher
a769071f72
fix check warnings
Signed-off-by: Matthew Fisher <matt.fisher@fishworks.io>
2021-11-05 11:38:06 -07:00
Ed Page
71ff62c37e Revert "Add no_auto_version_mut_args test"
This reverts commit 3a9d40fcb8.
2021-11-05 09:28:22 -05:00
Ed Page
3e838d1b77 Revert "Add partial_mut_args test"
This reverts commit 1c73c46af9.
2021-11-05 09:28:20 -05:00
Ed Page
2537894c4b Revert "Fix test to support env feature disabled"
This reverts commit 477f884af1.
2021-11-05 09:28:15 -05:00
Pavan Kumar Sunkara
736cb28dd0 Revert "Fixes group conflicting with arg which has default value"
This reverts commit 8c76556ac4.
2021-11-03 18:25:53 +00:00
Pavan Kumar Sunkara
706085d9c5 Revert "Fixes arg conflicting with group whose arg has default value"
This reverts commit 64a2866b09.
2021-11-03 18:25:25 +00:00
Pavan Kumar Sunkara
4e370bb093 Revert "Fixes group conflicting if two args with default values"
This reverts commit 01869744c2.
2021-11-03 18:24:50 +00:00
Pavan Kumar Sunkara
bd8c36cf04 Revert "Fixes arg and group with default value having requires"
This reverts commit 130dcbfdd9.
2021-11-03 18:22:19 +00:00
Pavan Kumar Sunkara
8818327b25 Revert "Fixes arg having required_if on default values"
This reverts commit a88562c12b.
2021-11-03 18:20:39 +00:00
Pavan Kumar Sunkara
6e85fb3ae0 Revert "Fixes arg having required_unless on default values"
This reverts commit ac1de1fc78.
2021-11-03 18:18:54 +00:00
bors[bot]
acaa3645c3
Merge #2980
2980: test: Easier to test with minimal features r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-11-02 22:02:31 +00:00
Ed Page
a9c6a5b531 refactor(tests): Remove unnecessary color disabling
The tests are using `to_string` which maps to `Display::fmt` and the
`Colorizer` version is colorless.  To get color, it is only supported
with `print()` which has to go to stdout / stderr and can't be directed
to an arbitrary stream.
2021-11-02 16:40:31 -05:00
Ed Page
ade6028da1 fix: Loosen reflection lifetimes
Though we store a lot of values as `&'help str`, we return them as
`&'self str`, making it so they can not be used programmatically as part
of a `App::mut_arg` call.

This loosens the lifetimes so they can be used with `App::mut_arg`.
This also includes a test simulating the desired workflow described in #2966

I skipped `get_all_aliases`.  I ran into problems with lifetimes with
`all_subcommand_names`  and didn't quickly resolve it.  Rather than hold
this up, I punted on it for now.

We'll have to tighten these back up with #1041 but that will also enable
turning them into owned strings, so this will still be possible after
that issue is resolved, just the calls will be slightly different.
2021-11-01 16:28:43 -05:00
Ed Page
66341b3c11 fix: Always respect positional occurrences
When supporting multiple occurrences for positional arguments in #2804,
I added some tests to cover this but apparently simpler cases fail
despite those more complicated cases being tested.

This adds more multiple-occurrences tests for positional arguments,
fixes them, and in general equates multiple values with occurrences for
positional arguments as part of #2692.  There are a couple more points
for consideration for #2692 for us to decide on once this unblocks them
(usage special case in #2977 and how subcommand help should be handled).

I fully admit I have not fully quantified the impact of all of these
changes and am heavily relying on the quality of our tests to carry this
forward.
2021-11-01 14:14:04 -05:00
Ed Page
53bd42a809 fix(usage)!: Separate mutli-occ from multi-val syntax
In looking at multiple occurrences and values for issues like #2692, I
noticed that `...` can mean both multiple values and multiple
occurrences, like before we split them.

Pros
- No syntax change with clap3

Cons
- All the reasons we split `multiple` into two

Uncertain
- I originally started this as part of another branch but I lost track
  if something depended on this.  I'll have to do more digging

BREAKING CHANGE: If `--opt [val]...` was meant for
- only multiple occurrences, see `[opt]... --opt [val]`
- both multiple occurrences and values, see `[opt]... --opt [val]...`
2021-10-30 12:56:49 -05:00
Johan Andersson
477f884af1 Fix test to support env feature disabled 2021-10-30 14:28:52 +02:00
Johan Andersson
1c73c46af9 Add partial_mut_args test 2021-10-30 13:37:34 +02:00
Johan Andersson
3a9d40fcb8 Add no_auto_version_mut_args test 2021-10-30 13:01:13 +02:00
Pavan Kumar Sunkara
2984748762 Fix some test cases to print correct failure message 2021-10-29 18:48:23 +01:00
Pavan Kumar Sunkara
92977060be
Allow r_unless_all to be used along with r_unless_any 2021-10-28 00:10:30 +01:00
bors[bot]
0d7a0a81c2
Merge #2950
2950: Fix default value behaviour with conflicts and requirement validation r=pksunkara a=pksunkara



Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2021-10-27 20:16:21 +00:00
Pavan Kumar Sunkara
0cbec63489 Make sure that ArgMatches methods panic on unknown arg, not return false 2021-10-27 02:42:30 +01:00
Pavan Kumar Sunkara
ac1de1fc78
Fixes arg having required_unless on default values 2021-10-26 22:27:10 +01:00
Pavan Kumar Sunkara
a88562c12b
Fixes arg having required_if on default values 2021-10-26 22:18:01 +01:00
Pavan Kumar Sunkara
130dcbfdd9
Fixes arg and group with default value having requires 2021-10-26 22:18:01 +01:00
Pavan Kumar Sunkara
01869744c2
Fixes group conflicting if two args with default values 2021-10-26 22:18:00 +01:00
Pavan Kumar Sunkara
64a2866b09
Fixes arg conflicting with group whose arg has default value 2021-10-26 22:18:00 +01:00
Pavan Kumar Sunkara
8c76556ac4
Fixes group conflicting with arg which has default value 2021-10-26 22:18:00 +01:00
Pavan Kumar Sunkara
bf91a1a35a
Improve debug assert for required group and default value interaction 2021-10-26 22:17:59 +01:00
Pavan Kumar Sunkara
b21c15f8b6
Dedupe some tests and improve others 2021-10-26 22:17:59 +01:00
Ed Page
bfa388420b Put grouped_values_of behind a feature gate
There is enough open work on this, we should probably not have it public
yet, so putting it behind a gate.  See https://github.com/clap-rs/clap/issues/2924
2021-10-26 14:26:50 -05:00
Ed Page
9f12bfec47 fix!: Rename ArgValue to PossibleValue
In considering potential work for #2683, I realized we might need a type to carry data for
each of the `multiple_values`.  `ArgValue` works both for that and for
possible values, so we need to come up with a better name for one or
both.  Changing `ArgValue`s name now would be ideal since its new in
clap3 and by renaming it, we can reduce churn for users.

While thinking about this, I realized I regularly get these mixed
up, so renaming `ArgValue` to `PossibleValue` I think will help clear
things up, regardless of #2683.
2021-10-19 10:10:37 -05:00
rhysd
8a7d217fe6 fix(test): Fix 'unused return value' lint warnings 2021-10-19 16:34:05 +09:00
rhysd
012f318c97 feat(doc): Fix many typos in docs, comments and codes found by typos-cli 2021-10-19 10:38:22 +09:00
Pavan Kumar Sunkara
e63760e461 Allow possible_values to take string vector reference
Makes it more backward compatible and flexible
2021-10-17 17:01:18 +01:00
bors[bot]
1c2b09e57b
Merge #2890
2890: feat: Expose clap-style errors to users r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-17 00:12:07 +00:00
Ed Page
b9cc585997 feat: Expose clap-style errors to users
This gives users the basic error template for quick and dirty messages.
In addition to the lack of customization, they are not given anything to help
them with coloring or for programmayic use (info, source).

This is something I've wanted many times for one-off validation that
can't be expressed with clap's validation or it just wasn't worth
the hoops.  The more pressing need is for #2255, I need `clap_derive`
to be able to create error messages and `Error::with_description` seemed
too disjoint from the rest of the clap experience that it seemed like
users would immediately create issues about it showing up.

With this available, I've gone ahead and deprecated
`Error::with_description` (added in 58512f2fc), assuming this will be
sufficient for users needs (or they can use IO Errors as a back door).
I did so according to the pattern in #2718 despite us not being fully
resolved on that approach yet.
2021-10-16 19:03:17 -05:00
bors[bot]
d78d5a3744
Merge #2899
2899: Allow RegexSet for validator_regex r=epage a=pksunkara



Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2021-10-16 21:40:07 +00:00
Pavan Kumar Sunkara
7dc176ab2a Allow RegexSet for validator_regex 2021-10-16 22:30:52 +01:00
bors[bot]
b835ce9061
Merge #2817
2817: Add support for Multicall executables as subcommands with a Multicall setting r=pksunkara a=fishface60



Co-authored-by: Richard Maw <richard.maw@gmail.com>
2021-10-16 00:32:52 +00:00