Commit graph

4307 commits

Author SHA1 Message Date
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
Johan Andersson
0dded91541
Fix docs variable name
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2021-10-30 12:55:46 +02:00
Johan Andersson
6e4ac4cffc Add App::mut_args 2021-10-30 12:26:15 +02:00
bors[bot]
2ce916133b
Merge #2961 #2965
2961: Pin the zola version used to deploy the site r=epage a=pksunkara



2965: fix(error): Never show unrequested color r=pksunkara a=epage



Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-29 23:00:12 +00:00
bors[bot]
98c5f78d3b
Merge #2964
2964: test(derive): Verify derive-genned errors are formatted r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-29 21:53:08 +00:00
Ed Page
6126f998d1 fix(error): Never show unrequested color
If the user prints a raw error, it may include color even if the user
turned it off at runtime.  Now we'll be more conservative and never show
color for raw errors.

This is a follow up to #2943; apparently I had missed some cases.
2021-10-29 16:28:23 -05:00
Ed Page
93c26dd420 test(derive): Verify derive-genned errors are formatted
This is to help verify behavior added in #2943.  We separated the error
raising site from the error formatting site and this verifies that the
formatting actually happens.
2021-10-29 16:09:07 -05:00
bors[bot]
7ce5d79de3
Merge #2962
2962: Fix some test cases to print correct failure message r=epage a=pksunkara



Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2021-10-29 17:59:20 +00: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
2ffb49ccff
Pin the zola version used to deploy the site 2021-10-29 17:07:49 +01:00
bors[bot]
b5e390008c
Merge #2957
2957: Allow r_unless_all to be used along with r_unless_any r=ldm0 a=pksunkara



Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2021-10-29 15:45:05 +00:00
bors[bot]
0ad042ac0b
Merge #2959
2959: Update site r=pksunkara a=pksunkara



Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2021-10-28 23:06:52 +00:00
Pavan Kumar Sunkara
34ac79f9b0 Update site 2021-10-28 21:08:22 +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
Ed Page
4835c00419 fix: Ease transition for now-default settings
We prefer Settings to always be off by default, so when we change a
default, we have to rename.

This adds back in the now-default settings with deprecation messages to
help the user know how things now work.

Unfortunately, there is no way to notify the user that the default they
relied on has changed.  This also doesn't help us when the change in
behavior is more than just an inverting, like `InvalidUtf8` or when a
setting mapped to multiple bits.
2021-10-27 13:07:06 -05:00
Ed Page
99058014d8 fix: Allow using deprecated color AppSettings
This partiall reverts commit efeb02cd34,
bringing back the `AppSettins::Color*` and making them the backing store
for `App::color`, to help ease the transition from clap2->3.

Once we remove these deprecated settings, we might want to keep this
backing store to save on memory.

This is a part of #2617
2021-10-27 13:07:06 -05:00
Ed Page
88b89317ab fix: Ease clap2->3 transition with renamed Settings
This brings back the old name of settings, just deprecated.  Since they
all map to the same bits in the bit field, this should work for
`setting` and `is_set`.  The only thing this lacks is being able to do
equality across variants, whcih seems like a minority case.

Removed settings have some extra care abouts that we'll need to look
into separately.

This is a part of #2617
2021-10-27 13:07:06 -05:00
bors[bot]
281eba244d
Merge #2000
2000: Make methods from ArgMatches panic on unknown argument r=pksunkara a=CreepySkeleton



Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2021-10-27 09:23:04 +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
bors[bot]
a802662341
Merge #2952 #2953
2952: fix(derive): Don't duplicate subcommand aliases r=pksunkara a=epage



2953: docs(app): Correlate help_heading and subcommand_placeholder r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-26 21:56:54 +00:00
Pavan Kumar Sunkara
ac1de1fc78
Fixes arg having required_unless on default values 2021-10-26 22:27:10 +01:00
Ed Page
f3fec3ed0f docs(app): Correlate help_heading and subcommand_placeholder
This is to increase the chance a user discovers what they are looking
for, by using similar terms and cross-linking.
2021-10-26 16:21:02 -05: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
c4fdb1dd42
Improve requirements validation by removing dead code 2021-10-26 22:18:00 +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
261a2c00e8
Added ArgMatcher::is_default_value abstraction 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
Pavan Kumar Sunkara
4edcda2b99
Revert "docs: Clarify corner caseses with default values"
This reverts commit 45ef0722f3.
2021-10-26 22:17:59 +01:00
Ed Page
d05622d015 fix(derive): Don't duplicate subcommand aliases
When an anonymous struct is inside of an enum, we end up applying the
App methods twice, once for the `augment_args` and once for variant.

This consolidates those calls.

Fixes #2898
2021-10-26 16:01:05 -05:00
bors[bot]
f9e074e554
Merge #2926 #2948
2926: Put `grouped_values_of` behind a feature gate r=pksunkara a=epage



2948: docs(generate): Move derive example to generate r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-26 20:56:20 +00:00
bors[bot]
07fcaa9597
Merge #2943
2943: fix(derive)!: Don't Panic, Error r=epage a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-26 19:47:09 +00: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
a065702205 docs(generate): Move derive example to generate
From a users perspective, `clap_derive` is baked into `clap`.
`clap_generate is an add on to `clap`.  So it seems best to have all
`clap_generate` examples in `clap_generate` where a user will look for
them.

Fixes #2939
2021-10-26 14:26:50 -05:00
Ed Page
53e10b41e3 fix(derive)!: Error, don't panic!
The derive is generating `Error::raw` (from scratch or by converting
existing erors) and then the inherent `Parser` methods format them.

Fixes #2255
2021-10-26 14:26:50 -05:00
Ed Page
f8bca3a84b fix(error): Never show unrequested color
If the user prints a raw error, it may include color even if the user
turned it off at runtime.  Now we'll be more conservative and never show
color for raw errors.
2021-10-26 14:26:50 -05:00
Ed Page
3c4340c583 feat(error): Allow separate raise, format sites
While `App::error` is what most people will need, `clap_derive` needs to
handle when the site raising the error doesn't have access to the `App`
and needs to defer that to later.
2021-10-26 14:26:50 -05:00
Ed Page
83b074ae92 refactor(error): Extract formatting of raw messages 2021-10-26 14:26:50 -05:00
Ed Page
f1bf9fc250 refactor(error): Delay formatting until the end
This gives us room to add extra context later.
2021-10-26 14:26:50 -05:00
bors[bot]
c0ac536cb7
Merge #2949
2949: fix(derive): Use variants help_heading r=epage a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-26 18:07:23 +00:00
Ed Page
69a7b7133a fix(derive): Use variants help_heading
Due to a copy/paste bug, we were reading the `help_heading` for
Subcommands from the enum's attribute and not the variant's attribute.

It doesn't make sense for the outer command's help_heading to control
the subcommands help_heading.

This does raise an interesting question on inheriting / propagating help_heading,
which I originally wrote the tests for.  We'd first need to answer
whether it should be built-in to the builder or derive-specific.
2021-10-26 12:49:43 -05:00
bors[bot]
b77b4e43a6
Merge #2942
2942: fix(derive): Support arg_enum everywhere r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-25 21:53:59 +00:00
Ed Page
5d036d4d34 fix(derive): Support arg_enum everywhere
In working on converting unwraps to errors, I noticed that we did not
spport `arg_enum` for  `Option<Option<_>>` and `Option<Vec<_>>`, so this
addresses that.

My main motivation was to consolidate and make the logic more
consistent, the bug fix just fell out of that work.
2021-10-25 14:12:08 -05:00
bors[bot]
29972e162a
Merge #2896
2896: docs: Clarify corner caseses with default values r=epage a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-25 16:48:17 +00:00
bors[bot]
d6462884ed
Merge #2941
2941: Fix a path incompatible with re-exports r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-25 15:40:33 +00:00