Provide a Arg::custom_parse
style function
#1185
Labels
A-parsing
Area: Parser's logic and needs it changed somehow.
C-enhancement
Category: Raise on the bar on expectations
S-wont-fix
Status: Closed as there is no plan to fix this
Something I've been thinking about for a while and mentioned in BurntSushi/ripgrep#809 is to add some additional functions which allow users to do something mid parse. From the linked issue:
However, now that I'm thinking about it, all three of those could actually be combined into a single
Arg::custom_parse
which accepts a function that takes the arg/value currently being parsed, and returns anOption<T>
whereNone
is skip this value (i.e. parse it as a different arg), orSome(T)
is "save this to the matches" it could be the value as passed in, or it could be something different entirely (i.e. amap
).This could also require a few companion methods on the matches struct that allows mutation. I'd like to expose these on a newtype wrapper
PartialMatches(ArgMatches)
so as not to expose these mutation functions on a regular basis. Functions could be something likePartialMatches::remove_{value,arg}
,PartialMatches::add_{value,arg}
, etc. It would also have all the normalArgMatches
methods provided via a facade.The text was updated successfully, but these errors were encountered: