Skip to content

hiroppy/cav

Repository files navigation

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.

About

A supporter for making your CLI.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published