nopt icon indicating copy to clipboard operation
nopt copied to clipboard

[FEATURE] Add a handler for *unknown* options, analogous to `invalidHandler`

Open mklement0 opened this issue 10 years ago • 2 comments

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.

mklement0 avatar Jan 30 '15 16:01 mklement0

This is exactly what I was just looking for.

ghost avatar Aug 25 '15 20:08 ghost

IMO, default behavior should be to throw and an .unknownHandler should be used to either change the behavior or print out a prettier message.

binki avatar May 30 '17 03:05 binki