Ed Page
f9be3215c1
refactor(parser): Minor clean up
2022-05-16 15:08:47 -05:00
Ed Page
352025f8cb
refactor(parser): Tweak specialization precedence
...
In theory, directly implemented types should have higher precedence than
inferring from another trait.
2022-05-16 15:08:47 -05:00
Ed Page
50e7308c22
refactor(parser): Reduce chance of bugs in specialization
2022-05-16 15:08:47 -05:00
Ed Page
a3965918bc
doc(parser): Explain built-in motivation
2022-05-16 15:08:47 -05:00
Ed Page
d52be32e8e
fix(parser): Don't bake-in ArgEnum
2022-05-16 15:08:47 -05:00
Ed Page
a798858ced
feat(parser): Verify possible values
2022-05-16 15:08:47 -05:00
Ed Page
9d07b3c028
feat(parser): non-empty string ValueParser
2022-05-16 15:08:47 -05:00
Ed Page
ecc5b2f3e9
feat(parser): Support ArgEnum with ValueParser
2022-05-16 15:08:47 -05:00
Ed Page
2902f190e4
refactor(error): More flexible callers
2022-05-16 15:08:47 -05:00
Ed Page
56aaf0baf2
feat(parser): Expose env-like bool parsers
...
Still unsure what should be the default but this at least makes it
easier for people to choose.
2022-05-16 15:08:47 -05:00
Ed Page
73fc240c57
refactor(env): Generalize bool policy
2022-05-16 15:08:47 -05:00
Ed Page
200f6626db
feat(parser): Add type information to arg values
...
To set the type, we offer
- `ValueParser::<type>` short cuts for natively supported types
- `TypedValueParser` for fn pointers and custom implementations
- `value_parser!(T)` for specialized lookup of an implementation
(inspired by #2298 )
The main motivation for `value_parser!` is to help with `clap_derive`s
implementation but it can also be convinient for end-users.
When reading, this replaces nearly all of our current `ArgMatches` getters with:
- `get_one`: like `value_of_t`
- `get_many`: like `values_of_t`
It also adds a `get_raw` that allows accessing the `OsStr`s without
panicing.
The naming is to invoke the idea of a more general container which I
want to move this to.
The return type is a bit complicated so that
- Users choose whether to panic on invalid types so they can do their
own querying, like `get_raw`
- Users can choose how to handle not present easily (#2505 )
We had to defer setting the `value_parser` on external subcommands,
for consistency sake, because `Command` requires `PartialEq` and
`ValueParser` does not impl that trait. It'll have to wait until a
breaking change.
Fixes #2505
2022-05-16 15:08:33 -05:00
Ed Page
740bb39f50
Merge pull request #3728 from AndreasBackx/issue/3259
...
feat(builder): Updated min_value and required docs
2022-05-16 08:57:14 -05:00
Andreas Backx
a678baa4f4
feat(builder): Updated min_value and required docs
2022-05-14 21:06:52 +01:00
Ed Page
dcf69d1c87
refactor(parser): Track str/OsStr values via Box
...
Unfortunately, we can't track using a `ValueParser` inside of `Command`
because its `PartialEq`. We'll have to wait until a breaking change to
relax that.
Compatibility:
- We now assert on using the wrong method to look up defaults. This
shouldn't be a breaking change as it'll assert when getting a real
value.
- `values_of`, et al delay panicing on the wrong lookup until the
iterator is being processed.
2022-05-12 16:13:30 -05:00
Ed Page
cf0282bdae
refactor: Remove dead code
2022-05-12 10:35:52 -05:00
Ed Page
02b4fed2aa
Merge pull request #3724 from epage/pub
...
feat: Expose builder/parser modules
2022-05-12 06:35:56 -05:00
Ed Page
17c99d2878
test(derive): Unsure why this is failing
2022-05-12 06:23:38 -05:00
Ed Page
399c138825
fix: Soft-deprecate several items within the root
2022-05-12 06:18:08 -05:00
Ed Page
4fea1515b6
feat: Expose builder/parser modules
...
The top-level API for clap is getting a bit bloated. By exposing these
modules, we'll be able to continue to add new, less commonly used types
while keeping the main API focused.
2022-05-12 06:17:08 -05:00
Ed Page
524e36cf1a
chore: Release
2022-05-10 15:29:16 -05:00
Ed Page
6635237037
docs: Update changelog
2022-05-10 15:28:50 -05:00
Ed Page
20d95d2b8c
Merge pull request #3718 from epage/arg_enum
...
fix(macros): Add needed call for arg_enum
2022-05-10 15:18:04 -05:00
Ed Page
52f6939044
fix(macros): Add needed call for arg_enum
...
Fixes #3717
2022-05-10 14:43:04 -05:00
Ed Page
9713cd9ae4
Merge pull request #3712 from epage/assert
...
fix(assert): Make sure group members exist before using them
2022-05-10 14:40:26 -05:00
Ed Page
7c1f9123a4
fix(assert): Make sure group members exist before using them
...
In #3711 , we had a confusing assert about no non-default members of a
required group when there were no defaults involved. This is because
there were no valid args in the group but that check happens after.
2022-05-09 15:53:18 -05:00
Ed Page
a57a4119a1
Merge pull request #3708 from epage/rename_sub
...
fix(derive): Don't change case of Arg id's (unstable)
2022-05-09 10:48:36 -05:00
Ed Page
2e3540355a
fix(derive): Don't change case of Arg id's (unstable)
...
This will make it easier to reference arguments with different
attributes.
Fixes #3282
2022-05-09 10:36:03 -05:00
Ed Page
f7e4dd23d6
refactor(derive): Divide rename_all assertions
2022-05-06 16:47:52 -05:00
Ed Page
ddc9d54f41
refactor(derive): Generalize test name
2022-05-06 16:45:03 -05:00
Ed Page
fe4888d668
refactor(derive): Group subcommand rename tests
2022-05-06 16:43:23 -05:00
Ed Page
fbb01d8b33
Merge pull request #3703 from epage/external
...
fix(parser): Disambiguate whether built-in subcommands are escaped (unstable)
2022-05-06 16:18:21 -05:00
Ed Page
eb155786bb
fix(parser): Assert on unknown args when using external subcommands (unstable)
2022-05-06 15:49:33 -05:00
Ed Page
65538e21a8
fix(derive): Detect escaped ambiguous subcommands (unstable)
2022-05-06 15:46:34 -05:00
Ed Page
630dde7bf2
Merge pull request #3702 from epage/derive
...
feat(derive): Start `unstable-v4` feature flag
2022-05-06 15:08:13 -05:00
Liu Dingming
1b63fbd6df
feat(derive): Start unstable-v4
feature flag
...
This is split out of #3661 as several changes I'm working on need it.
2022-05-06 14:56:55 -05:00
Ed Page
36f8e470dd
Merge pull request #3701 from epage/required
...
fix(assert): Detect conflicting arguments (unstable)
2022-05-06 14:45:41 -05:00
Ed Page
6ceb865c95
fix(assert): Detect conflicting arguments (unstable)
...
Fixes #3660
2022-05-06 14:29:35 -05:00
Ed Page
122b4b4ac1
Merge pull request #3700 from epage/value_name
...
fix(help): Define value name / number of values mismatch relationships
2022-05-06 14:15:47 -05:00
Ed Page
3d7ee2e5cd
fix(assert): Verify required_unless_present_all exist
2022-05-06 14:11:37 -05:00
Ed Page
089f96eb87
fix(help): Disallow too many value names (unstable)
...
I can't think of a case for this or a way to render it.
Fixes #2695
2022-05-06 13:54:07 -05:00
Ed Page
70c29e3dd8
fix(help): Use '...' when not enough value names supplied
2022-05-06 13:33:17 -05:00
Ed Page
20ff4ce05a
doc(parser): Document external subcommand escaping behavior
2022-05-06 12:38:23 -05:00
Ed Page
03f132129b
fix(parser): Always put in arg ""
for external subcommands (unstable)
...
This allows distinguishing external subcommands from built-in
subcommands which can especially be confusing when escaping subcommands.
Fixes #3263
2022-05-06 12:25:20 -05:00
Ed Page
55e791e80e
chore: Release
2022-05-06 11:57:48 -05:00
Ed Page
ed0c01993c
docs: Update changelog
2022-05-06 11:57:39 -05:00
Evgeniy Terekhin
229b44d9bb
fix(macros): Allow dashed values ( #3699 )
...
add support for dashed arg names and values in arg! macro
2022-05-06 10:58:00 -05:00
Ed Page
95698a4f31
chore: Release
2022-05-06 09:39:24 -05:00
Ed Page
3984e55363
docs(complete): Update changelog
2022-05-06 09:39:15 -05:00
Ed Page
1a1a842aa0
Merge pull request #3698 from epage/value
...
fix(complete): Complete visible, rather than hidden, values
2022-05-06 09:37:54 -05:00