JSPM

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

A cli lib.

Package Exports

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

Readme

3h-cli

A cli lib.

Install

$ npm install 3h-cli

Example

In MyCLI.js:

const CLI = require('3h-cli');

const cli = CLI.create({
    name: 'MyCLI',
    title: 'Here is the title.'
}).set({
    filter: true,
    tabSize: 3,
    nameSize: 4,
    gapSize: 6
}).first({
    name: 'a',
    val: 'v1',
    help: 'Help for\nthe first arg.'
}).arg({
    name: 'h',
    help: 'Show this.'
}).arg({
    name: 'b',
    val: 'v2',
    help: 'Arg "b".'
}).on('extra', key => {
    console.log(`Unknown arg "${key}"!`);
}).on('error', err => {
    console.log('An error occurred!');
    console.error(err);
}).on('exec', args => {
    args.forEach((v, k) => {
        console.log(`Received ${k}->${JSON.stringify(v)}.`);
    });
    if (args.has('h')) {
        console.log('(Here is the help info:)');
        cli.help();
    }
}).exec(process.argv);

In the command line:

> node MyCLI firstArg
Received a->["firstArg"].

>node MyCLI -h
Received h->[].
(Here is the help info:)
Here is the title.

MyCLI <v1> [options]

   <v1>      Help for
             the first arg.
   -h        Show this.
   -b  <v2>  Arg "b".

API

Just read 3h-cli.d.ts to learn about the APIs. ( By the way, that file is specified in package.json for typescript users. )