structopt
has a neat feature where it can it accept a typed argument for Vec<T>
that will gobble the rest of the command line.
#[structopt(long, short)]
values: Vec<u32>,
It also has the ability to accept a type you create,
If the field type does not have a
FromStr
implementation, or you would like to provide a custom parsing scheme other thanFromStr
, you may provide a custom string parser usingparse(...)
Can the type that you create not be a scalar and either have multiple values or wrap a Vec<T>
is there a method to create a custom parser for a type that wraps Vec<T>
but reorders it's arguments or a struct that includes more than one field, for example like this
struct Positionals {
first: String,
increment: String,
last: String
}
I need a different structure because the arguments name is contingent on the ordering, (if there is one argument it's just "last" if there is two arguments the first argument is not last, it's "first" and the second argument is "last"). I was wondering if there was a way to write a parser that understands these nuances (as above) or can reorder a vector to accommodate for them.