JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 24
  • Score
    100M100P100Q48651F
  • License MIT

more greedy argument parser like a minimist!

Package Exports

  • chopsticks

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (chopsticks) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Chopsticks

WIP

Installation

npm install chopsticks --save

Usage

chopsticks(args, opts={}) -> argv

  • opts.string
  • opts.boolean
  • opts.alias
  • opts.default
  • opts.stopEarly
  • opts.dash (aka opts['--'])
  • opts.unknown

minimist-v1.2.0 spec completed.

New features

  • emoji support can use emoji to short flags 👍

    node -e 'console.log(require("minimist")(["-🍣👹👺"]))'
    # { _: [], '�': '�👹👺' }
    
    node -e 'console.log(require("chopsticks")(["-🍣👹👺"]))'
    # { '🍣': true, '👹': true, '👺': true, _: [] }
  • opts.unknown=true if specify is true, returne the detailed object at argv.unknown.

    parse(['-f', 'true', '--no-foo', 'true', 'noop!', '--', 'huh']);
    // {
    //   "_": [
    //     "huh"
    //   ],
    //   "unknown": [
    //     {
    //       "type": "short",
    //       "origin": "f",
    //       "alias": [],
    //       "name": "f",
    //       "value": "true"
    //     },
    //     {
    //       "type": "long",
    //       "origin": "foo",
    //       "alias": [],
    //       "name": "foo",
    //       "value": false
    //     },
    //     "true",
    //     "noop!"
    //   ]
    // }
  • opts.array - the specified flag takes the following argument continually. (like a npm-run-all)

    // $ node program.js -s cover lint report -s foo bar baz -- huh
    parse(process.argv.slice(2),{array:'s'});
    // {
    //   "_": [
    //     "huh"
    //   ],
    //   "s": [
    //     ['cover', 'lint', 'report'],
    //     ['foo', 'bar', 'baz']
    //   ]
    // }
  • opts.sentence - (WIP) if true, comma nearby argument, is defined in "sentence". and ignore the last period of the argument. (like a abigail)

    // $ node program.js cover, lint, report. 'foo bar', baz. huh -- huh
    parse(process.argv.slice(2),{array:'s'});
    // {
    //   "_": [
    //     "huh",
    //     "huh"
    //   ],
    //   "sentence": [
    //     ['cover', 'lint', 'report'],
    //     ['foo bar', 'baz']
    //   ]
    // }

Development

Requirement global

  • NodeJS v5.10.0
  • Npm v3.8.3
git clone https://github.com/59naga/chopsticks
cd chopsticks
npm install

npm test

License

MIT