3-14 minimist.js


const args = require('minimist')(process.argv.slice(2))

console.log(process.argv.slice(2))

console.log(args)

  // lijiaming jm-npm-package % node npm/npm-minimist.js --hello=word
  { _: [], hello: 'word' }

  // lijiaming jm-npm-package % node npm/npm-minimist.js --hello=word heool
  { _: [ 'heool' ], hello: 'word' }

  // lijiaming jm-npm-package % node npm/npm-minimist.js --hello=word heool 22323
  { _: [ 'heool', 22323 ], hello: 'word' }

  // lijiaming jm-npm-package % node npm/npm-minimist.js --hello=word heool 22323 678
  { _: [ 'heool', 22323, 678 ], hello: 'word' }

  // lijiaming jm-npm-package % node npm/npm-minimist.js --hello=word heool 22323 678
  [ '--hello=word', 'heool', '22323', '678' ]
  { _: [ 'heool', 22323, 678 ], hello: 'word' }