JSPM

tiny-opts-parser

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

    A tiny options parser.

    Package Exports

    • tiny-opts-parser

    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 (tiny-opts-parser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    An extremely lightweight CLI options parser.

    Install via npm or yarn

    > npm install --save tiny-opts-parser

    And then just use import (or require if you need to):

    import parser from 'tiny-opts-parser';

    In node, command line input is passed to application as an array. Tiny Opts Parser takes this array as its first argument, and an options object as its (optional) second argument. Tiny Opts Parser returns an object that maps the name of each argument or option to its value. The output will be exactly the same as the output of all the popular JS CLI parsers like Commander, Minimist, and Yargs.

    For those who are new to CLI options parsing, the process can get quite complicated. For example, if someone types the following on the command line: mycommand -a -bcd def xyz --abcd, the parser needs to know turn this into the following object:

    {
      _: ['xyz'],
      a: true,
      b: true,
      c: true,
      d: 'def',
      abcd: true,
    }