Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inconsistent parsing of numeric arguments #19

Open
lightmare opened this issue Dec 24, 2021 · 0 comments
Open

inconsistent parsing of numeric arguments #19

lightmare opened this issue Dec 24, 2021 · 0 comments

Comments

@lightmare
Copy link

// x.js
import minimist from "minimist"
import mri from "mri"

const OPTIONS = { boolean: [ 'flag' ], array: [ { key: '_', number: true } ] }

console.log('minimist', minimist(process.argv.slice(2), OPTIONS))

console.log('mri', mri(process.argv.slice(2), OPTIONS))
$ node x.js 10 20 xx 40
minimist { _: [ 10, 20, 'xx', 40 ], flag: false }
mri { _: [ '10', '20', 'xx', '40' ] }
$ node x.js --flag 10 20 xx 40
minimist { _: [ 10, 20, 'xx', 40 ], flag: true }
mri { _: [ 10, '20', 'xx', '40' ], flag: true }
$ node x.js 10 --flag 20 xx 40
minimist { _: [ 10, 20, 'xx', 40 ], flag: true }
mri { _: [ '10', 20, 'xx', '40' ], flag: true }

It appears mri converts a single argument after a flag to number. I would expect it to convert all (like minimist) or none.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant