JSPM

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

A tool for rapidly parse command line arguments or options

Package Exports

  • @devnetic/cli

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

Readme

@devnetic/cli

npm (scoped) npm bundle size (scoped) npm GitHub issues GitHub

A tool for rapidly parse command line arguments or options.

Usage

Parse cli arguments:

const { getParams } = require('@devnetic/cli')

const params = getParams()

if (params.help || params.h) {
  console.log('Help option is used')
}

// execute with node index.js --help or node index.js -h

Using the usage function to create a help for our command line tools:

const { usage } = require('@devnetic/cli')

usage('Usage: $0 <command> [options]')
  .option(['-f', '--file'], 'Load a file', 'red')
  .option(['-h', '--help'], 'Show help', 'blue')
  .example('$0 -f foo.js', 'count the lines in the given file')
  .epilog('copyright 2019', 'green')
  .show()

Using the format function to custom messages for our command lines tools:

const { format } = require('@devnetic/cli')

const error = format.bold().red

console.log(format.white(JSON.stringify(fixed, null, '  ')))
console.log(format.bold().italic().red(JSON.stringify(params, null, '  ')))

console.log(error('Unexpeted Error!'))
console.log(format.bold().yellow('This is a Warning!'))