pkgjs / parseargs

Polyfill of `util.parseArgs()`
Apache License 2.0
121 stars 9 forks source link

should "--" signal an end to parsing? #58

Closed bcoe closed 2 years ago

bcoe commented 2 years ago

Perhaps we should just put -- in _, and an implementer could fallback to calling slice on process.argv, if they observe it?

ljharb commented 2 years ago

Yes, double dash should signal an end to parsing.

shadowspawn commented 2 years ago

I assume _ is positionals. Not sure if you are wondering about ending the option processing, or about whether to include -- in positionals. In any case, a short answer...

I am happy with the currently implemented behaviour, that the -- is consumed and the remaining arguments are put into positionals (and not examined for options).

(I suggested README changes describing the current behaviour for -- in abandoned #34.)

bnb commented 2 years ago

Yes, this is generally the DX I've seen in Node.js-based tooling.

shadowspawn commented 2 years ago

The current behaviour implemented in parseArgs is the same as in all the reference implementations from #76:

try-getopt-long % ./ex foo -- bar --option
non-option ARGV-elements: foo bar --option 

try-commander % node index.js foo -- bar --option
positionals: [ 'foo', 'bar', '--option' ]

try-yargs % node index.js foo -- bar --option
{ _: [ 'foo', 'bar', '--option' ], '$0': 'index.js' }

try-minimist % node index.js foo -- bar --option
{ _: [ 'foo', 'bar', '--option' ] }