It's not possible to determine whether a flag was passed more than once. (Or I can't find it.)
A flag is either present or absent, and ArgResult.flag returns a bool.
The callback is only called once, even if the flag is present multiple times.
There is no way to distinguish -vv from -v, where the former is a known and used format for increasing a verbosity level by two.
What is needed is a flag-based equivalent of a "multi-option".
There is no need to introduce a new addMultiFlag, any flag can count its positive occurrences, and ArgResult.flag(name) can just return whether than number is greater than zero.
Then there can be an ArgResult.flagCount(name) that returns this number.
A --no-the-flag, if allowed, resets the flag count to zero.
It's not possible to determine whether a flag was passed more than once. (Or I can't find it.)
A flag is either present or absent, and
ArgResult.flagreturns abool.The
callbackis only called once, even if the flag is present multiple times.There is no way to distinguish
-vvfrom-v, where the former is a known and used format for increasing a verbosity level by two.What is needed is a flag-based equivalent of a "multi-option".
There is no need to introduce a new
addMultiFlag, any flag can count its positive occurrences, andArgResult.flag(name)can just return whether than number is greater than zero.Then there can be an
ArgResult.flagCount(name)that returns this number.A
--no-the-flag, if allowed, resets the flag count to zero.