Commit graph

5652 commits

Author SHA1 Message Date
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
Ed Page
6f2c4aff90 refactor(parser): Clean up ValueParser 2022-05-16 15:08:47 -05:00
Ed Page
f3d8ef248f feat(complete): Complete value_parser possible values 2022-05-16 15:08:47 -05:00
Ed Page
0088b1643c feat(parser): Track ValueParser's possible values
This will let us replace `Arg::possible_values` completely by letting
completions check these.
2022-05-16 15:08:47 -05:00
Ed Page
2e57f1fca7 fix(parser): Disallow empty paths 2022-05-16 15:08:47 -05:00
Ed Page
ec186487b6 refactor(parser): Have ValueParser delegate built-ins 2022-05-16 15:08:47 -05:00
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