nopt
nopt copied to clipboard
[FEATURE] Add a handler for *unknown* options, analogous to `invalidHandler`
Currently (v3.0.1), nopt invariably accepts unknown options and simply adds them to the object returned.
However, a typical use case for a CLI is to abort processing in case an unknown option is specified.
Thus, an .unknownHandler property specifying a function to call on encountering an unknown option would be handy - analogous to the existing .invalidHandler property for handling invalid option values.
I'd be happy to implement this.
This is exactly what I was just looking for.
IMO, default behavior should be to throw and an .unknownHandler should be used to either change the behavior or print out a prettier message.