busterjs / buster

Abandoned - A powerful suite of automated test tools for JavaScript.
http://docs.busterjs.org
Other
448 stars 37 forks source link

[posix-argv-parser] Compound short options and operands are conflated #394

Closed jcoglan closed 10 years ago

jcoglan commented 10 years ago

(Posting here on the advice of @cjno due to busterjs/posix-argv-parser not having issues open.)

This program:

var pap = require('posix-argv-parser'),
    parser = pap.create();

parser.createOption(['--config', '-c'], {hasValue: false});
parser.createOption(['--length', '-l'], {hasValue: true});
parser.createOperand('service');

parser.parse(['-cl', '10'], function(error, options) {
  console.error(error);
  console.log(options);
});

Produces the following output:

{ '--config': 
   { isSet: true,
     value: undefined,
     timesSet: 1,
     signature: '--config/-c' },
  '-c': 
   { isSet: true,
     value: undefined,
     timesSet: 1,
     signature: '--config/-c' },
  '--length': { isSet: true, value: '', timesSet: 1, signature: '--length/-l' },
  '-l': { isSet: true, value: '', timesSet: 1, signature: '--length/-l' },
  service: { isSet: true, value: '10', timesSet: 1, signature: 'service' } }

Whereas it should set --length to '10' and leave service undefined.

dwittner commented 10 years ago

Fixed by bba3e4cc3f.