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
Ed Page
1a2b7acd60
test(multicall): Conditionalize suggestion-related case
...
This impacts the error code (#3676 ) and the error body and without
suggestions, its redundant.
2022-05-20 12:20:40 -05:00
Ed Page
0628d04174
perf(derive): Reuse allocations for external subcommands
...
In case the `ArgMatches` is cloned, this forces a constraint that the
underlying type impls `Clone` but that should be safe as we only support
`String` and `OsString`.
2022-05-20 12:02:31 -05:00
Ed Page
d61552a8b8
refactor(derive): Deconstruct arg matches into enums
2022-05-20 11:56:47 -05:00
Ed Page
18f295029f
refactor(derive): Consistently handle sub matches
2022-05-20 11:10:26 -05:00
Ed Page
b817c2d2a9
refactor(derive): Separate sub flattening to avoid aliasing
2022-05-20 11:08:05 -05:00
Ed Page
17ec775789
Merge pull request #3736 from epage/edition
...
fix: Switch to 2021 edition
2022-05-18 10:55:33 -05:00
Ed Page
2abb6804d3
fix: Switch to 2021 edition
2022-05-18 10:35:30 -05:00
Ed Page
d827364ea9
style: Normalize manifests
2022-05-18 10:33:37 -05:00
Ed Page
272334b26a
fix: List rust-version for all crates
2022-05-18 10:08:10 -05:00
Ed Page
5806e16dd4
refactor(derive): Don't alias arg matches
...
Right now, the aliasing is safe (the compiler says so!) but we're going
to be switching to a `&mut` and need to ensure we don't alias.
2022-05-18 09:38:38 -05:00
Ed Page
1446be8a89
feat(derive): Allow destructively constructing from ArgMatches
2022-05-18 09:10:55 -05:00
Ed Page
28ee3d33f7
Merge pull request #3732 from epage/domain
...
feat(builder): Custom parser for arg values
2022-05-17 19:15:54 -05:00
Ed Page
4a733cd879
fix: Bump MSRV to 1.56.0
...
This is needed for `Bound::cloned` and fits within official MSRV policy
(2 versions back) and unofficial (6 months, see #3267 )
2022-05-17 17:13:08 -05:00
Ed Page
acdf26ac38
style: Make clippy happy
2022-05-17 17:13:08 -05:00
Ed Page
c9e3b81e3c
doc(parser): Specify what unwraps are for
2022-05-17 16:58:38 -05:00
Ed Page
91fe9eedc9
feat(parser): Transfer ownership of sub-matches
2022-05-17 16:58:38 -05:00
Ed Page
675ac68f73
fix(parser): Give more flexibility for changes
2022-05-17 16:58:38 -05:00
Ed Page
0033bf60c1
style: Address clippy complaints
2022-05-17 14:11:04 -05:00
Ed Page
63aa236141
feat(parser): Convenient range value parsers
...
There are several approaches with this
- `value_parser(N..M)`: creates an i64 range
- `value_parser(value_parser!(u16).range(10..))`: creates an u16 range
that starts at 10
- `RangeI64ValueParser`: create whatever range you want
I was hoping to generalize `RangeI64ValueParser` for any source type,
not just i64, but ran into issues and decided to punt. I chose `i64` as
the source type as it seemed the most general and didn't run into
portability issues like `isize`.
This is a step towards #3199 . All that is left is for the derive to use
this.
2022-05-17 14:00:52 -05:00
Ed Page
6b0306df9e
feat(parsr): Expose all built-in TypedValueParsers
...
This makes life easier for people, whether they want a geneirc
`NonEmpty<impl TypedValueParser>` or a `PathBufExists(PathBuf)`.
2022-05-16 17:16:42 -05:00
Ed Page
2ffa38f9f5
feat(parser): Implicitly turn possible values into a value parser
2022-05-16 17:07:35 -05:00
Ed Page
f86d881e3a
docs(parser): Polish ValueParser docs
2022-05-16 16:54:05 -05:00
Ed Page
d826ab9445
fix(derive): Move args to new 'get_one'/'get_many' API
2022-05-16 15:16:51 -05:00
Ed Page
72c44a32e5
fix(derive): Move subcommands to new 'get_many' API
2022-05-16 15:16:51 -05:00
Ed Page
41f13bd0ce
feat(complete): Path value parsers imply Path completion hints
2022-05-16 15:15:55 -05:00
Ed Page
d2ca18130e
feat(parser): Allow removing values from ArgMatches
...
This allows reducing the use of `Clone`, especially in `clap_derive`.
2022-05-16 15:08:47 -05:00
Ed Page
792fb54990
fix(parser): Be consistently strict with ArgMatches types
...
This gives us more implementation freedom for the future.
2022-05-16 15:08:47 -05:00
Ed Page
c7bd8c891d
perf(parser): Don't allocate on every call
2022-05-16 15:08:47 -05:00
Ed Page
36236957e4
fix(parser): Allow invalid id lookups without panics
...
Fixes #3621
2022-05-16 15:08:47 -05:00
Ed Page
c331be98a5
fix(parser): Separate dev errros from user errors
2022-05-16 15:08:47 -05:00
Ed Page
66570ee9d0
refactor(parser): Set source at start of occurrence
2022-05-16 15:08:47 -05:00
Ed Page
7cb2a096d0
refactor(parser): Force explicit occurrence start
2022-05-16 15:08:47 -05:00
Ed Page
0d6be4e1a8
refactor(parser): Consistently start occurrences
2022-05-16 15:08:47 -05:00
Ed Page
5532bfc838
refactor(parser): Clarify env code
2022-05-16 15:08:47 -05:00
Ed Page
4845296949
refactor(parser): Clarify default value code
2022-05-16 15:08:47 -05:00
Ed Page
8a58884459
refactor(parser): Initialize MatchedArg from its source
2022-05-16 15:08:47 -05:00
Ed Page
e6b1468477
fix(parser): Set source/occurrences for external subcommands
2022-05-16 15:08:47 -05:00
Ed Page
d538012a74
refactor(parser): separate concerns over external subcommands
2022-05-16 15:08:47 -05:00
Ed Page
772c5e3821
feat(lex): Allow checking if at end of input
2022-05-16 15:08:47 -05:00
Ed Page
0e04367826
fix(parser): Consistently log parser
2022-05-16 15:08:47 -05:00
Ed Page
c74d3fb045
refactor(parser): Reduce visibility
2022-05-16 15:08:47 -05:00
Ed Page
144cd4c3b7
refactor(parser): Group default/env
2022-05-16 15:08:47 -05:00
Ed Page
8c3f540638
refactor(parser): Clarify name for starting occurrences
2022-05-16 15:08:47 -05:00
Ed Page
f296c5ca78
refactor(parser): Fix naming of ty
2022-05-16 15:08:47 -05:00
Ed Page
bc6da813bd
fix(parser): Unify handling of AnyValue's type id
2022-05-16 15:08:47 -05:00
Ed Page
9920d5baf5
fix(parser): Improve AnyValue debug output
2022-05-16 15:08:47 -05:00
Ed Page
8b582c3007
refactor(parser): Make AnyValue opaque
...
This gives a little more implementation flexibility
2022-05-16 15:08:47 -05:00
Ed Page
f16a6fb5a6
refactor(parser): Move AnyValue definition closer to use
2022-05-16 15:08:47 -05:00
Ed Page
bdf9d841ef
doc(parser): Expand examples for ValueParser
...
This identified a problem with the blanket implementations for
`TypedValueParser`: it only worked on function pointer types and not unnamed
function tupes. The user has to explicitly decay the function type to a
function pointer to opt-in, so I changed the blanket impl. The loss of
the `OsStr` impl shouldn't be too bad.
2022-05-16 15:08:47 -05:00