Commit graph

5665 commits

Author SHA1 Message Date
Ed Page
d7879f107c
Merge pull request #3756 from epage/regex
fix(validator): Deprecate validator_regex
2022-05-25 14:46:10 -05:00
Ed Page
ae97550638 fix(validator): Deprecate validator_regex
Fixes #3743
2022-05-25 14:32:00 -05:00
Ed Page
52c1841d87
Merge pull request #3755 from epage/factory
feat(parser): Allow people to plug into 'value_parser' macro
2022-05-25 14:28:14 -05:00
Ed Page
fcdd31781b feat(parser): Allow people to plug into 'value_parser' macro
For most users, this won't be worth doing, they can just specify the
parser if needed.  Where this has value is crates that integrate custom
types into clap, like creating click-like file integration.  See
https://click.palletsprojects.com/en/8.0.x/arguments/#file-arguments
2022-05-25 14:12:27 -05:00
Ed Page
999647f6a0
Merge pull request #3753 from epage/deprecate
fix: Deprecate value_parser predecesor
2022-05-25 13:26:37 -05:00
Ed Page
408ca3c5d7 test(derive): Update for deprecations 2022-05-25 13:13:22 -05:00
Ed Page
814d30b1de fix(parser): Deprecate is_valid_arg 2022-05-25 13:00:51 -05:00
Ed Page
a712adefcd fix(parser): Deprecate value_of and friends 2022-05-25 12:57:11 -05:00
Ed Page
256643f8d3 fix: Deprecate possible_values 2022-05-25 12:57:11 -05:00
Ed Page
573d496bc6 fix: Deprecate forbid_empty_values 2022-05-25 12:57:11 -05:00
Ed Page
177511dab1 fix: Deprecate validator / validator_os
`validator_regex` is being ignored for now as I await on a comment
period for #3743
2022-05-25 12:57:11 -05:00
Ed Page
f15a1aab1a fix: Deprecate allow_invalid_utf8 2022-05-25 12:57:11 -05:00
Ed Page
5b6d68f247 fix(parser): Show cause of panic in backtrace 2022-05-25 12:57:11 -05:00
Ed Page
9b5b49ceec fix(parser): Error, don't panicon on get_many type mismatch 2022-05-25 12:57:11 -05:00
Ed Page
a9b3acfc40
Merge pull request #3752 from epage/panic
fix(parser): Improve panic messages for get_one, etc
2022-05-25 12:31:40 -05:00
Ed Page
a1df333ccd fix(parser): Improve panic messages for get_one, etc 2022-05-25 12:10:30 -05:00
Ed Page
ef3121cbdf
Merge pull request #3751 from epage/try
fix(parser): Simplify the common getter API
2022-05-25 11:22:32 -05:00
Ed Page
bac68e5d30 docs(parser): Fix links 2022-05-25 11:00:46 -05:00
Ed Page
18793d9db7 docs(parser): Fix typos 2022-05-25 10:56:48 -05:00
Ed Page
21be77c854 docs(parser): Group args / subcommand funcs separately 2022-05-25 10:52:02 -05:00
Ed Page
eda0ca54c1 fix(parser): Simplify the common getter API
Clap has focused on reporting development errors through assertions
rather than mixing user errors with development errors.  Sometimes,
developers need to handle things more flexibly so included in #3732 was
the reporting of value accessor failures as internal errors with a
distinct type.  I've been going back and forth on whether the extra
error pessimises the usability in the common case vs dealing with the
proliferation of different function combinations.  In working on
deprecating the `value_of` functions, I decided that it was going to be
worth duplicating so long as we can keep the documentation focused.
2022-05-25 10:50:42 -05:00
Ed Page
5aea9adbb6
Merge pull request #3750 from epage/iter
fix(parser): Switch to concrete iterators
2022-05-25 10:46:20 -05:00
Ed Page
53948db66f style: Make clippy happy 2022-05-25 10:25:57 -05:00
Ed Page
78b6f1ee64 fix(parser): Default construct ArgMatches::remove_many's Iterator 2022-05-25 10:19:05 -05:00
Ed Page
2891a73b2e fix(parser): Default construct ArgMatches::get_many's Iterator 2022-05-25 10:19:05 -05:00
Ed Page
a4e8cc96f9 fix(parser): Default construct ArgMatches::get_raw's Iterator 2022-05-25 10:19:05 -05:00
Ed Page
0c4a4f17de
Merge pull request #3747 from epage/clone
fix(parser): Clean up remove types
2022-05-24 16:39:40 -05:00
Ed Page
ed45de2f03 fix(parser): Clean up remove types
The remove functions no longer return `Arc` but the core type, at the
cost of requiring `Clone`.  I originally held off on this
in #3732 in the hope of gracefully transition the derive and requiring
`Clone` would have been a breaking change but when it came to #3734, I didn't
find a way to make it work without a breaking change, so I made it
opt-in.  This means I can force the `Clone` requirement now.

I added the requirement for `Clone` everywhere else in the hopes that in
the future, we can drop the `Arc` without a breaking change.
2022-05-24 16:25:07 -05:00
Ed Page
bf86f76306
Merge pull request #3746 from epage/fixes
fix(parser): Increase compatibility between old/new approach
2022-05-24 15:09:19 -05:00
Ed Page
b3847d12f0 docs(ref): Update for _ref derive 2022-05-24 14:53:08 -05:00
Ed Page
33e94df212 docs(example): Update for value_parser 2022-05-24 14:53:08 -05:00
Ed Page
9a913c40e1 fix(help): Show possible values long help 2022-05-24 14:53:08 -05:00
Ed Page
c6a3871544 fix(error): Include PossibleValuesParser values in error 2022-05-24 14:53:08 -05:00
Ed Page
30f2879824 fix: Include value_parser in debug output 2022-05-24 14:53:08 -05:00
Ed Page
a997ee7e10 fix(derive): Improve where errors point 2022-05-24 14:53:08 -05:00
Ed Page
15616bbd13 fix(error): Remove usage from value validation
When to show usage?  We are currently mixed about it.  For `validator`,
we didn't show it at all.  Sometimes we show the used arguments and
sometimes we don't.

With `ValueParser`, I ran into the problem that we weren't showing the
used arguments like we had previously in some cases.  In deciding how to
solve this, I went with the simplest route for now and removed it as the
usage likely doesn't add much context to help people solve their
problem, more so the recommendation for help.  We'll see how the
feedback is on this and adjust.
2022-05-23 20:56:04 -05:00
Ed Page
19dac49fab
Merge pull request #3742 from epage/derive3
feat(derive): Allow users to opt-in to `ValueParser`
2022-05-23 10:33:38 -05:00
Ed Page
e23800e10e doc(derive): Update for value_parser 2022-05-20 20:02:23 -05:00
Ed Page
852a1b15d4 fix(help): Show value_parser's PossibleValues 2022-05-20 19:59:36 -05:00
Ed Page
5b4ea8e56e fix(parser): Print proper upper range bound 2022-05-20 19:48:06 -05:00
Ed Page
2fba6155ec refactor(derive): Separate concerns when removing 2022-05-20 19:27:52 -05:00
Ed Page
a35df14caf feat(derive): Opt-in to inferred value_parser 2022-05-20 19:25:20 -05:00
Ed Page
7845e604e7 perf(derive): Reuse allocations where possible
Only bothered to implement this for `value_parser` cases as `parse`
cases are going to be considered deprecated.
2022-05-20 15:44:19 -05:00
Ed Page
b52c7f115e feat(derive): Allow users to opt-in to ValueParser
For clap 3, its opt-in as a precaution against breaking
compatibility in some weird cases.

This does require the types to implement `Clone`.

Fixes #3734
Fixes #3496
Fixes #3589
2022-05-20 15:38:44 -05:00
Ed Page
b202eed3d5
Merge pull request #3740 from epage/ui
test: Re-enable ui tests
2022-05-20 14:23:57 -05:00
Ed Page
d1d67fd68d
Merge pull request #3739 from epage/bool
fix(parser): Use optimized bool value parser
2022-05-20 14:11:11 -05:00
Ed Page
e0e7383300 test: Re-enable ui tests
`derive_ui.rs` did not have a marker for needing to be updated on MSRV
changes, so it got missed.
2022-05-20 14:10:32 -05:00
Ed Page
5171fce186 fix(parser): Use optimized bool value parser 2022-05-20 12:50:52 -05:00
Ed Page
5de3639666
Merge pull request #3684 from epage/multicall
feat: Stablize multicall
2022-05-20 12:42:53 -05:00
Ed Page
686b0379ce feat(multicall): Stablize multicall
`multicall` allows you to have one binary expose itself as multiple
programs, like busybox does.  This also works well for user clap for
parsing REPLs.

Fixes #2861
2022-05-20 12:20:40 -05:00