Commit graph

4555 commits

Author SHA1 Message Date
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
bors[bot]
693fae5090
Merge #2875
2875: Performance "Improvements" r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-18 22:18:38 +00:00
Ed Page
e2865c91be perf: Reduce allocations on 'args'
This seems like it'd have close to the same benefits as the suggestion
in the TODO, resolving it.
2021-10-18 16:14:31 -05:00
Ed Page
294cabf7c6 perf: Don't allocate a throw-away Vec 2021-10-18 16:14:31 -05:00
bors[bot]
33d86effc9
Merge #2904
2904: Prepare release 3.0.0-beta.5 r=pksunkara a=pksunkara



Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2021-10-17 16:10:55 +00:00
Pavan Kumar Sunkara
585e995811 Release 3.0.0-beta.5 2021-10-17 17:01:18 +01: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]
d3b33953de
Merge #2902
2902: Minor cosmetic: Place default/env/… on separate lines for multiline help output r=pksunkara a=jcaesar



Co-authored-by: Julius Michaelis <glitter@liftm.de>
2021-10-17 14:00:16 +00:00
Julius Michaelis
16af4f230a cosmetic: spec_vals on separate lines for long help 2021-10-17 22:43:06 +09:00
bors[bot]
98532ebddc
Merge #2903
2903: feat(generate): reduce dependencies of clap_generate (42 to 13) r=pksunkara a=rhysd



Co-authored-by: rhysd <lin90162@yahoo.co.jp>
2021-10-17 06:40:50 +00:00
rhysd
33efcf1665 feat(generate): reduce dependencies of clap_generate (42 to 13) 2021-10-17 14:31:16 +09: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]
badad6c088
Merge #2895
2895: fix(derive): Don't leak help headings r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-16 18:58:23 +00:00
bors[bot]
8647302296
Merge #2718
2718: fix: Ease clap2->clap3 migration with deprecations r=epage a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-16 17:52:21 +00:00
Ed Page
65e4bf232d fix(derive): Don't leak help headings
Before, when `flatten`ing, the struct you flattened in could set the
help heading for all the following arguments.  Now, we scope each
`flatten` to not do that.

I had originally intended to bake this into the initial / final methods
but that would have required some re-work to allow capturing state
between them that seemed unnecessary.

Fixes #2803
2021-10-16 11:21:16 -05:00
bors[bot]
6eacd8a747
Merge #2882
2882: fix(derive): Ensure App help_heading is applied r=epage a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-16 02:47:34 +00:00
bors[bot]
219d59a57a
Merge #2891
2891: refactor: Use USAGE_CODE constant r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-16 01:40:15 +00:00
Ed Page
d3c85773c0 refactor: Use USAGE_CODE constant
I missed a case in #2604.  This will help people discover the
documentation describing why we chose the code we did.
2021-10-15 19:39:00 -05: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
bors[bot]
afd9efc108
Merge #2887
2887: fix(help): Partial fix for 'help help' r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-15 23:38:17 +00:00
Ed Page
81e877c6c2 fix(help): Partial fix for 'help help'
Who knew people need to ask `help` for how to use `help`?

While auditing `MultpleValues`, I saw commented out code.   Looks
its commit (f230cfedc) was part of a large refactor and updating that
part fell through the cracks.  Just simply updating it didn't quite get
it to work.  The advantage of this approach is it gets us closer to how
clap works on its own.

In clap 2.33.3, `cmd help help` looks like
```
myapp-help
Prints this message or the help of the given subcommand(s)

USAGE:
    test-clap help [subcommand]...

ARGS:
    <subcommand>...    The subcommand whose help message to display
```

But clap3 master looks like:
```
myapp

USAGE:
    myapp [SUBCOMMAND]

OPTIONS:
    -h, --help    Print custom help about text

SUBCOMMANDS:
    help      Print this message or the help of the given subcommand(s)
    subcmd
```

This change improves it to:
```
myapp-help

Print this message or the help of the given subcommand(s)

USAGE:
    myapp help [SUBCOMMAND]...

ARGS:
    <SUBCOMMAND>...    The subcommand whose help message to display

OPTIONS:
    -h, --help    Print custom help about text
```

We still have global arguments showing up (like `-h`) that will error but its
an improvement!  In general, I'd like to find a way to leverage clap's stanard
behavior for implementing this so we don't have to worry about any of these
corner cases in the future.

Note: compared to clap2, I changed `<subcommand>` to `<SUBCOMMAND>` because I
believe the standard convention is for value names to be all caps (e.g.
`clap_derive` has been updated to default to that).
2021-10-15 18:24:15 -05:00
bors[bot]
2795ccd70d
Merge #2888
2888: refactor(derive): Simplify 'error' handling r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-15 21:28:36 +00:00