Closed
Description
This came up here, but I wanted to split it out to track it explicitly.
I think that reporting the indexes of arguments within args
would be a helpful addition, because it lets you build a bunch of more complicated logic on top of parseArgs
without needing to do a full re-parse.
For example, this would make it straightforward to:
- resolve conflicts between
--foo
and--no-foo
as last-wins - throw on duplicate flags (check if the flag occurs at multiple indexes)
- if someday defaults are added, check to see if an option was provided by a user or came from the default (Restructure result conventions (again) #70 (comment))
- enforce that value-taking arguments are all specified using
--foo=bar
rather than--foo bar
(check each to see ifargs[index].includes('=')
) - enforce that two flags are specified in a specific order (
--enable-experimental-options
before--some-unstable-option
, e.g.)