cav

0.1.0 • Public • Published

cav

npm version

A supporter for making your CLI.

Install

$ npm i -S cav

Examples

#!/usr/bin/env node
 
// sample-cli
 
const Cav = require('cav');
const packageJson = require('./package.json');
 
const commands = {
  'deploy <to> <env>'            : 'Deploy to ec2.',
  'migrate <from> <to> <version>': 'Migrate data.',
  '-f'                           : '',
  '-c, --current-state'          : 'Show Current State.'
};
 
const cav = new Cav(commands, packageJson);
 
cav.start((args) => {
  console.log(args)
});

Parse arguments

$ sample-cli deploy japan prod -f -c ok
cav.start((args) => {
  console.log(JSON.stringify(args, null, 2));
  //  {
  //    "commands": {
  //      "deploy": {
  //        "to": "japan",
  //        "env": "prod"
  //      }
  //    },
  //    "options": {
  //      "f": true,
  //      "c": "ok"
  //    }
  //  }
});

help

Version:    1.0.0

Usage:      sample-cli <commands> <options>

Commands:
            deploy <to> <env>                 Deploy to ec2.
            migrate <from> <to> <version>     Migrate data.
Options:
            -v, --version                     Display version.
            -h, --help                        Display help.
            -f                                ✊
            -c, --current-state               Show Current State.

Readme

Keywords

Package Sidebar

Install

npm i cav

Weekly Downloads

1

Version

0.1.0

License

MIT

Last publish

Collaborators

  • hiroppy