Skip to content

Allow flags to occur multiple times, and reveal how many. #937

@lrhn

Description

@lrhn

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions