meszaros-lajos-gyorgy / minimist-lite

parse argument options
Other
15 stars 3 forks source link

Add option to disable numeric conversion for arguments #12

Open micalevisk opened 2 years ago

micalevisk commented 2 years ago

Original issue by @whitlockjc at https://github.com/substack/minimist/issues/36

const argv = require('minimist-lite')(process.argv.slice(2))
console.dir(argv)

If I invoke my command using my-command 2.3, I end up with something like this:

{ _: [ 2.3 ] }

I realize if this was an option I could use opts.string to tell minimist to treat my option as a string but looks like there's no way to achieve the same for argument.

What I expect instead:

{ _: [ '2.3' ] }
micalevisk commented 2 years ago

I do agree with this comment

Implicit coercing for the rest arguments is not a good default and should be off by default.

Thus we can add this new option using false by default, and then changing it to true in the next major relase.

meszaros-lajos-gyorgy commented 2 years ago

I would vote on keeping the original behavior just to not introduce a breaking change, but having an option to control that is definitely a good idea.

micalevisk commented 2 years ago

I believe this will fix this other issue: https://github.com/substack/minimist/issues/112

$ node example/parse.js 002e1234
{ _: [ Infinity ] }