pub enum Index {
Forward(usize),
Backward(usize),
List(Vec<usize>),
Except(Vec<usize>),
Range(usize, usize),
AnyWhere,
Null,
}Expand description
Index using for option match.
The index is the position of left arguments (non-option arguments, NOA) index, its base on 1.
Example
foo.exe -a=value -b value pos1 --aopt=42 pos2 --bopt value pos3
| | | | | | | | |
| | | | | | | | NOA @3 or @-1
| | | | | | | value of --bopt
| | | | | | option --bopt
| | | | | NOA @2 or @-2
| | | | option --aopt and its value 42
| | | NOA @1
| | value of -b
| option -b
option -a and its value
Variants§
Forward(usize)
The forward index of NOA.
Example
For ["--aopt", "--bopt=42", "pos1", "--copt", "pos2", "--dopt", "value", "pos3"]:
@1 will matching "pos1".
@2 will matching "pos2".
@3 will matching "pos3".
Backward(usize)
The backward index of NOA.
Example
For ["--aopt", "--bopt=42", "pos1", "--copt", "pos2", "--dopt", "value", "pos3"]:
@-1 will matching "pos3".
@-2 will matching "pos2".
@-3 will matching "pos1".
List(Vec<usize>)
The include list of forward index of NOA.
Example
For ["--aopt", "--bopt=42", "pos1", "--copt", "pos2", "--dopt", "value", "pos3"]:
@[1,3] will matching "pos1" or "pos3".
@[1,2] will matching "pos1" or "pos2".
@[1,2,3] will matching "pos1", "pos2" or "pos3".
Except(Vec<usize>)
The exclude list of forward index of NOA.
Example
For ["--aopt", "--bopt=42", "pos1", "--copt", "pos2", "--dopt", "value", "pos3"]:
@-[1,3] will matching "pos2".
@-[3] will matching "pos1" or "pos2".
@-[2] will matching "pos1" or "pos3".
Range(usize, usize)
The NOA which index inside in given position range with format (m..n].
Example
For ["--aopt", "--bopt=42", "pos1", "--copt", "pos2", "--dopt", "value", "pos3"]:
@0.. will matching "pos1", "pos2" or "pos3".
@2.. will matching "pos2", "pos3".
@1.. will matching "pos1", "pos2" or "pos3".
@..4 will matching "pos1", "pos2" or "pos3".
@..2 will matching "pos1".
@1..3 will matching "pos1", "pos2".
AnyWhere
The anywhere position of NOA.
Example
For ["--aopt", "--bopt=42", "pos1", "--copt", "pos2", "--dopt", "value", "pos3"]:
@* or @0 will matching "pos1", "pos2" or "pos3".