Commit graph

4379 commits

Author SHA1 Message Date
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
Ed Page
345694fea8 fix(derive): Allow subcommands with re-exporting
Our approach to re-exporting is to not fully qualify symbols in `clap`.
This is a place where a leading `::` got introduced, so its being
removed.
2021-10-25 09:44:38 -05:00
Ed Page
92fea91dfe doc(derive): Note derive policies 2021-10-25 09:44:05 -05:00
bors[bot]
c8d7d4fbc8
Merge #2927
2927: test: Verify clap_derive README r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-25 14:33:26 +00:00
Ed Page
ed987933cf test: Verify clap_derive README
Fixes #2920
2021-10-25 09:21:45 -05:00
bors[bot]
5672bf9529
Merge #2930
2930: feat(derive): Allow `help_heading` on flattening fields r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-24 23:21:45 +00:00
bors[bot]
28a043de8d
Merge #2938
2938: refactor(error): Make 'Error' less churn heavy r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-24 21:57:57 +00:00
Ed Page
e5f10c81bc feat(derive): Allow help_heading on flattening fields
Fixes #2928
2021-10-23 16:05:08 -05:00
Ed Page
45ef0722f3 docs: Clarify corner caseses with default values
This is meant to lower the chance of confusion with cases like #2714 and #1586.

This is not meant to be exhaustive, looked at the mentioned cases in
that issue and pattern matched on other ones mentioning "is present".
2021-10-23 16:04:10 -05:00
Ed Page
a5ab5f0359 refactor(error): Make 'Error' less churn heavy
When I'm making changes, I frequently have to touch every error
function.  This creates a more standard builder API so we can more
easily add or modify fields without having to update every case.
2021-10-23 16:04:10 -05:00
Ed Page
01055fb796 docs(yaml): Consistently place layout descriptio 2021-10-23 16:04:10 -05:00
bors[bot]
3f933e1743
Merge #2935
2935: fix(derive): Avoid name collisions with users r=epage a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-23 19:50:28 +00:00
Ed Page
3a697af253 fix(derive): Avoid name collisions with users
PR #2751 highlighted a problem we have where the variable names we use
could collide with users.  Rather than parse out when or not to use
special names, and worry about people keeping that up to date through
refactors, I globally renamed all variables by adding a `__clap_`
prefix, which looks like what serde does to solve this problem.

I audited the result with `cargo expand`.  I didn't add any tests
because any tests would be reactionary and would give us a false sense
of protection since any new code could hit this with anything we do.
Our best route for naming is consistency so people are likely to notice
and copy.

Fixes #2934
2021-10-23 12:55:30 -05:00
Ed Page
4a6430c3a0
Merge pull request #2923 from epage/just
chore: Remove unused justfile
2021-10-23 10:29:11 -05:00
Ed Page
3ceb3c256e chore: Remove unused justfile
This was a kbknapp thing and he doesn't use it anymore.  See #2900.
2021-10-23 10:23:17 -05:00
Ed Page
201353c8c6
Merge pull request #2925 from epage/clippy
chore: Silence bad clippy lint
2021-10-23 10:21:28 -05:00
Ed Page
cebbb5c40e chore: Silence bad clippy lint
While in some cases "branches-sharing-code" might catch bugs, it overall encourages a form
of DRY that leads to bad code.  In this specific case, it is relying on
the implementation detail of the formatting of each branch being the
same.  If the `'` wasn't part of it, I could see it being about a shared
`?` to go with the shared start of the question.
2021-10-23 10:06:38 -05:00
bors[bot]
15f9cad81a
Merge #2919
2919: Fix packaging of LICENSE-* files r=pksunkara a=Jake-Shadle



Co-authored-by: Jake Shadle <jake.shadle@embark-studios.com>
2021-10-22 00:49:05 +00:00
Jake Shadle
db2a25473a Fix packaging of LICENSE-* files 2021-10-21 14:57:49 +02:00
bors[bot]
fed159fa62
Merge #2918
2918: docs: fix affect/effect usage r=epage a=cherryblossom000



Co-authored-by: cherryblossom000 <31467609+cherryblossom000@users.noreply.github.com>
2021-10-21 12:39:24 +00:00
cherryblossom000
5555416f45
docs: fix affect/effect usage 2021-10-21 19:29:08 +11:00
bors[bot]
c4dfb1aede
Merge #2916
2916: fix ArgEnum multiline doc comment r=epage a=marjakm



Co-authored-by: Mattis Marjak <mattis.marjak@gmail.com>
2021-10-19 17:06:14 +00:00
bors[bot]
07ec0440bf
Merge #2908
2908: fix!: Rename ArgValue to PossibleValue r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-19 15:58:56 +00:00
Mattis Marjak
cba7ba5369 fix ArgEnum multiline doc comment 2021-10-19 18:34:54 +03: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
bors[bot]
fe29af7a63
Merge #2909
2909: feat(doc): Fix many typos in docs, comments and codes found by typos-cli r=pksunkara a=rhysd



Co-authored-by: rhysd <lin90162@yahoo.co.jp>
2021-10-19 11:28:04 +00:00
rhysd
8a7d217fe6 fix(test): Fix 'unused return value' lint warnings 2021-10-19 16:34:05 +09:00
rhysd
e666763acf feat(doc): Fix positions of indices 2021-10-19 16:30:25 +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