adjacent is not working if first argument requires more than one item to succeed
Opened this issue · 2 comments
pacak commented
let x = short('x').argument::<f32>("X");
let y = short('y').argument::<f32>("Y");
let p = short('p').req_flag(());
construct!(p, x, y)
Without p
this fails since adjacent detects left most item with magic...
- rethink adjacency detection?
- expose more items somehow?
- document that adjacent block must start with a flag?
- use "left off the first item" logic only when there are positional items and narrowing window otherwise
polarathene commented
- document that adjacent block must start with a flag?
Is this related to the bugs experienced with a subcommand with overlapping flags (short names)?: #325
pacak commented
Is this related to the bugs experienced with a subcommand with overlapping flags (short names)?:
I don't think so. Current logic to restrict scope to adjacent values is something like this:
- run the parser showing it each unconsumed item individually, parser will fail, but it might start consuming items. Set this position as a starting point for the region
- run the parser again, showing it items from the start of the region until the end of the span of adjacent unconsumed items
- if consumed blocks are all adjacent to each other - that's the result, if not - narrow the span to adjacent block and goto 2.
This works if first item in the parser wants to consume let's say -p
, but it doesn't work if it wants let's say -x 3
- -x
part will be available, 3
- won't be and argument parser checks that both name and value are present. It works this way because some unrelated reasons.