minimistjs / minimist

parse argument options
MIT License
530 stars 30 forks source link

Incorrect handling of values beginning with - (dash) #16

Closed topaz1008 closed 1 year ago

topaz1008 commented 1 year ago

Hello.

I have come across a problem with handling key-value options where the value starts with a - (dash) and there is no = (equals) sign. I am using Windows10 and Node.js v18.12.1

Describe the exact steps which reproduce the problem

// test.js
import minimist from 'minimist';

const options = minimist(process.argv.slice(2));
console.log(options);

Running the following command gives this output:

> node test.js --command "-c:v copy"
{ _: [], command: true, c: ':v copy' }

Expected output:

> node test.js --command "-c:v copy"
{ _: [], command: '-c:v copy' }

When writing out the command using an = (equals), it works as expected. e.g.

> node test.js --command="-c:v copy"
{ _: [], command: '-c:v copy' }
topaz1008 commented 1 year ago

https://github.com/minimistjs/minimist/issues/15