v5.0.0
Breaking changes from v4.0.7
- Unknown values now throw an exception (
UNKNOWN_VALUE
) by default in the same way unknown options do. Command-line-args is now strict by default - all options and values must be accounted for in the option definitions.- An example of an unknown value is the arg
5
in the command--verbose 5
where verbose is defined as aBoolean
. - "Strict by default" behaviour can be disabled using either
partial
orstopAtFIrstUnknown
parse options.
- An example of an unknown value is the arg
- Setting a singular, non-multiple option more than once (e.g.
--help --help
) now throws anALREADY_SET
exception. - The multiple error names (
NAME_MISSING
,INVALID_TYPE
etc) thrown by commandLineArgs in the case of an invalid definition have been consolidated to just one error name:INVALID_DEFINITIONS
. Given broken option definitions are a programmer error they'd never be handled anyway, making the various names pointless.
New documentation
New parse features
- stopAtFirstUnknown
- camelCase
- the
UNKNOWN_OPTION
exception now has aoptionName
property containing the arg that specified an unknown option, e.g.--one
- the
ALREADY_SET
exception has aoptionName
property containing the option name that has already been set, e.g.one
- the
UNKNOWN_VALUE
exception has avalue
property containing the unknown value, e.g.5
New option definition features
Bug fixes
- #67 unknown "--option=value notation" value consumed as defaultOption
- #68 unknown --option=value arg split when defaultOption set
Upgrade notes
No API changes were introduced in v5.0.0 - it is backward-compatible. If you're comfortable with the new version throwing exceptions on unknown values, you are safe to upgrade without code change.