Skip to content

inconsistent parsing of numeric arguments #19

Description

@lightmare
// 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions