Does structopt support multi-contextual positional arguments?

152 Views Asked by At

I'm trying to port seq to structopt, how should I support,

seq [OPTION]... LAST
seq [OPTION]... FIRST LAST
seq [OPTION]... FIRST INCREMENT LAST

Notice, that the position of the LAST argument changes in the argument list, for completeness it would be nice to know BOTH,

  • Whether or not structopt supports varying positional arguments that are contextual and if so how?
  • Whether or not structopt supports a position argument that is right-anchored and if so how?
1

There are 1 best solutions below

0
On

I don't believe it's possible, and when I try I get a generated error:

Found positional argument which is not required with a lower index than a required positional argument

This means that the required arguments must come first. The best I think you can do is declare your last argument to be a Vec<Strings>

#[structopt(required=true)]
args: Vec<String>,