JSPM

@tcbox/command-parser

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

Parse nodejs process.argv in to json.

Package Exports

  • @tcbox/command-parser
  • @tcbox/command-parser/command-parser.cjs.min.js
  • @tcbox/command-parser/command-parser.es.min.js

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

Readme

Command Parser

Parse Command line and process.argv.

Demo

Usage

npm install command-parser

parseCommand

import {parseCommand} from "command-parser";
const commands = parseCommand(`
    node index.js -D |
    npm install
`);

result is

[
  {
    "name": "node",
    "args": [
      "index.js"
    ],
    "options": {
      "D": true
    }
  },
  {
    "name": "npm",
    "args": [
      "install"
    ],
    "options": {}
  }
]

parseArgv

This is only for nodejs

import {parseArgv} from "command-parser";
const command = parseArgv();

CDN

<script src="https://cdn.jsdelivr.net/npm/command-parser"></script>
<script>console.log(window.CommandParser) </script>