-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(builder): Custom parser for arg values #3732
Commits on May 12, 2022
-
Configuration menu - View commit details
-
Copy full SHA for cf0282b - Browse repository at this point
Copy the full SHA cf0282bView commit details -
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.
Configuration menu - View commit details
-
Copy full SHA for dcf69d1 - Browse repository at this point
Copy the full SHA dcf69d1View commit details
Commits on May 16, 2022
-
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 clap-rs#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 (clap-rs#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 clap-rs#2505
Configuration menu - View commit details
-
Copy full SHA for 200f662 - Browse repository at this point
Copy the full SHA 200f662View commit details -
Configuration menu - View commit details
-
Copy full SHA for 73fc240 - Browse repository at this point
Copy the full SHA 73fc240View commit details -
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.
Configuration menu - View commit details
-
Copy full SHA for 56aaf0b - Browse repository at this point
Copy the full SHA 56aaf0bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 2902f19 - Browse repository at this point
Copy the full SHA 2902f19View commit details -
Configuration menu - View commit details
-
Copy full SHA for ecc5b2f - Browse repository at this point
Copy the full SHA ecc5b2fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 9d07b3c - Browse repository at this point
Copy the full SHA 9d07b3cView commit details -
Configuration menu - View commit details
-
Copy full SHA for a798858 - Browse repository at this point
Copy the full SHA a798858View commit details -
Configuration menu - View commit details
-
Copy full SHA for d52be32 - Browse repository at this point
Copy the full SHA d52be32View commit details -
Configuration menu - View commit details
-
Copy full SHA for a396591 - Browse repository at this point
Copy the full SHA a396591View commit details -
Configuration menu - View commit details
-
Copy full SHA for 50e7308 - Browse repository at this point
Copy the full SHA 50e7308View commit details -
refactor(parser): Tweak specialization precedence
In theory, directly implemented types should have higher precedence than inferring from another trait.
Configuration menu - View commit details
-
Copy full SHA for 352025f - Browse repository at this point
Copy the full SHA 352025fView commit details -
Configuration menu - View commit details
-
Copy full SHA for f9be321 - Browse repository at this point
Copy the full SHA f9be321View commit details -
Configuration menu - View commit details
-
Copy full SHA for ec18648 - Browse repository at this point
Copy the full SHA ec18648View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2e57f1f - Browse repository at this point
Copy the full SHA 2e57f1fView commit details -
feat(parser): Track ValueParser's possible values
This will let us replace `Arg::possible_values` completely by letting completions check these.
Configuration menu - View commit details
-
Copy full SHA for 0088b16 - Browse repository at this point
Copy the full SHA 0088b16View commit details -
Configuration menu - View commit details
-
Copy full SHA for f3d8ef2 - Browse repository at this point
Copy the full SHA f3d8ef2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6f2c4af - Browse repository at this point
Copy the full SHA 6f2c4afView commit details -
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.
Configuration menu - View commit details
-
Copy full SHA for bdf9d84 - Browse repository at this point
Copy the full SHA bdf9d84View commit details -
Configuration menu - View commit details
-
Copy full SHA for f16a6fb - Browse repository at this point
Copy the full SHA f16a6fbView commit details -
refactor(parser): Make AnyValue opaque
This gives a little more implementation flexibility
Configuration menu - View commit details
-
Copy full SHA for 8b582c3 - Browse repository at this point
Copy the full SHA 8b582c3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9920d5b - Browse repository at this point
Copy the full SHA 9920d5bView commit details -
Configuration menu - View commit details
-
Copy full SHA for bc6da81 - Browse repository at this point
Copy the full SHA bc6da81View commit details -
Configuration menu - View commit details
-
Copy full SHA for f296c5c - Browse repository at this point
Copy the full SHA f296c5cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 8c3f540 - Browse repository at this point
Copy the full SHA 8c3f540View commit details -
Configuration menu - View commit details
-
Copy full SHA for 144cd4c - Browse repository at this point
Copy the full SHA 144cd4cView commit details -
Configuration menu - View commit details
-
Copy full SHA for c74d3fb - Browse repository at this point
Copy the full SHA c74d3fbView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0e04367 - Browse repository at this point
Copy the full SHA 0e04367View commit details -
Configuration menu - View commit details
-
Copy full SHA for 772c5e3 - Browse repository at this point
Copy the full SHA 772c5e3View commit details -
Configuration menu - View commit details
-
Copy full SHA for d538012 - Browse repository at this point
Copy the full SHA d538012View commit details -
Configuration menu - View commit details
-
Copy full SHA for e6b1468 - Browse repository at this point
Copy the full SHA e6b1468View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8a58884 - Browse repository at this point
Copy the full SHA 8a58884View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4845296 - Browse repository at this point
Copy the full SHA 4845296View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5532bfc - Browse repository at this point
Copy the full SHA 5532bfcView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0d6be4e - Browse repository at this point
Copy the full SHA 0d6be4eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7cb2a09 - Browse repository at this point
Copy the full SHA 7cb2a09View commit details -
Configuration menu - View commit details
-
Copy full SHA for 66570ee - Browse repository at this point
Copy the full SHA 66570eeView commit details -
Configuration menu - View commit details
-
Copy full SHA for c331be9 - Browse repository at this point
Copy the full SHA c331be9View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3623695 - Browse repository at this point
Copy the full SHA 3623695View commit details -
Configuration menu - View commit details
-
Copy full SHA for c7bd8c8 - Browse repository at this point
Copy the full SHA c7bd8c8View commit details -
fix(parser): Be consistently strict with ArgMatches types
This gives us more implementation freedom for the future.
Configuration menu - View commit details
-
Copy full SHA for 792fb54 - Browse repository at this point
Copy the full SHA 792fb54View commit details -
feat(parser): Allow removing values from ArgMatches
This allows reducing the use of `Clone`, especially in `clap_derive`.
Configuration menu - View commit details
-
Copy full SHA for d2ca181 - Browse repository at this point
Copy the full SHA d2ca181View commit details -
Configuration menu - View commit details
-
Copy full SHA for 41f13bd - Browse repository at this point
Copy the full SHA 41f13bdView commit details -
Configuration menu - View commit details
-
Copy full SHA for 72c44a3 - Browse repository at this point
Copy the full SHA 72c44a3View commit details -
Configuration menu - View commit details
-
Copy full SHA for d826ab9 - Browse repository at this point
Copy the full SHA d826ab9View commit details -
Configuration menu - View commit details
-
Copy full SHA for f86d881 - Browse repository at this point
Copy the full SHA f86d881View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2ffa38f - Browse repository at this point
Copy the full SHA 2ffa38fView commit details -
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)`.
Configuration menu - View commit details
-
Copy full SHA for 6b0306d - Browse repository at this point
Copy the full SHA 6b0306dView commit details
Commits on May 17, 2022
-
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 clap-rs#3199. All that is left is for the derive to use this.
Configuration menu - View commit details
-
Copy full SHA for 63aa236 - Browse repository at this point
Copy the full SHA 63aa236View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0033bf6 - Browse repository at this point
Copy the full SHA 0033bf6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 675ac68 - Browse repository at this point
Copy the full SHA 675ac68View commit details -
Configuration menu - View commit details
-
Copy full SHA for 91fe9ee - Browse repository at this point
Copy the full SHA 91fe9eeView commit details -
Configuration menu - View commit details
-
Copy full SHA for c9e3b81 - Browse repository at this point
Copy the full SHA c9e3b81View commit details -
Configuration menu - View commit details
-
Copy full SHA for acdf26a - Browse repository at this point
Copy the full SHA acdf26aView commit details -
This is needed for `Bound::cloned` and fits within official MSRV policy (2 versions back) and unofficial (6 months, see clap-rs#3267)
Configuration menu - View commit details
-
Copy full SHA for 4a733cd - Browse repository at this point
Copy the full SHA 4a733cdView commit details