how has this been in production for over a decade
> require('nopt')({ foo: String, bar: String }, {}, ['--foo', '--bar'], 0)
{
foo: '',
bar: ''
}
@jcoglan
Perhaps there's an "original sin", a blog post or conference talk that says "this is how NOT to do it", and everyone adopted it, similar to how "waterfall model" became a standard.
I am using commander 2.9.0 (graceful-readlink 1.0.1) on node v4.4.7 (on Windows, running in MSYS2, if it matters). I run the following test program: var commander = require("commander") commander ....
@jcoglan Can you work around this by declaring a default value, for example, as in https://github.com/tj/commander.js?tab=readme-ov-file#default-option-value ? It appears .argument() also supports a default. Some defaults such as 0 or the empty string might "obviously" equate to "not specified", even if they are surfaced to other user.
I think there might also be a way to not declare an argument and just get a list of positional arguments, but I don't remember exactly and this might produce ugly --help.