pub enum Index {
Forward(usize),
Backward(usize),
List(Vec<usize>),
Except(Vec<usize>),
Range(usize, Option<usize>),
AnyWhere,
Null,
}Expand description
Index using for option match.
The index is the position of left arguments (non-option arguments, NOA) index.
§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 valueFor option check, see SetChecker for more information.
Variants§
Forward(usize)
The forward index of NOA, fixed position.
§Example
For ["app", "--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, floating position.
§Example
For ["app", "--aopt", "--bopt=42", "pos1", "--copt", "pos2", "--dopt", "value", "pos3"]:
@-1 will matching "pos2".
@-2 will matching "pos1".
@-3 will matching "app".
List(Vec<usize>)
The include list of forward index of NOA, fixed position.
§Example
For ["app", "--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, floating position.
§Example
For ["app", "--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, Option<usize>)
The NOA which index inside in given position range with format (m..n].
If range have upper limit, the index is fixed position otherwise it is floating position.
§Example
For ["app", "--aopt", "--bopt=42", "pos1", "--copt", "pos2", "--dopt", "value", "pos3"]:
@0.. will matching "app", "pos1", "pos2" or "pos3".
@2.. will matching "pos2", "pos3".
@1.. will matching "pos1", "pos2" or "pos3".
@..4 will matching "app", "pos1", "pos2" or "pos3".
@..2 will matching "app", "pos1".
@1..3 will matching "pos1", "pos2".
AnyWhere
The anywhere position of NOA, floating position.
§Example
For ["app", "--aopt", "--bopt=42", "pos1", "--copt", "pos2", "--dopt", "value", "pos3"]:
@* will matching "app", "pos1", "pos2" or "pos3".