meszaros-lajos-gyorgy / minimist-lite

parse argument options
Other
15 stars 3 forks source link

BUG: function unknown called for non-options #1

Open meszaros-lajos-gyorgy opened 2 years ago

meszaros-lajos-gyorgy commented 2 years ago

Original issue by @johndeighan at https://github.com/substack/minimist/issues/161

when I pass this to parseArgs() (using 'import parseArgs from 'minimist';' in an ES6 module'):

[ 'test/TopMenuShort.starbucks' ]

For example, my command line is node myscript.js test/TopMenuShort.starbucks, my "unknown" function is called, and this is output (though I've realized that this line is printed by my "unknown" function):

Unknown option: -test/TopMenuShort.starbucks

But the return value from parseArgs() is correct:

{
  _: [ 'test/TopMenuShort.starbucks' ],
  c: false,
  j: false,
  s: false,
  h: false,
  d: false
}

My work around is to simply return true from my "unknown" function, but that still has the problem that I can't just print the "unknown option" error message. I'm pretty sure that the function should only be called for unknown options, not for non-options on the command line.