JSPM

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

CLI framework for Node.js that's qui-ck and easy

Package Exports

  • cli-ck

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

Readme

cli-ck

CLI framework for Node.js that's qui-ck and easy

cli-ck provides a simple and flexible interface for creating cli apps in Node.js. Inspired by the Yargs api, cli-ck provides an API that is flexible and composeable making it a breeze to write simple cli tools or complex interactive repl's.

Synopsis

easy.js

#!/usr/bin/env node
require('babel-polyfill')
var Click = require('../lib/cli-ck')
var cli = new Click()
    .description('demonstrates the cli-ck module')
    .version('1.0.0')
    .option('fruit', {
        alias: 'f',
        desc: 'Type of fruit',
        choices: [ 'apple', 'banana', 'peach', 'pear' ]
    })
    .command('say', { desc: 'Say words in different ways' }, require('./say'))
    .handler(function(args, opts) {
        console.log('please choose a command')
    })
cli.run(process.argv)

say.js

#!/usr/bin/env node
require('babel-polyfill')
var Click = require('../lib/cli-ck')
var cli = new Click()
    .usage('$0 say [--volume {soft,medium,loud}] <...words>')
    .option('volume', {
        alias: 'v',
        desc: 'how loud do you want to say it? [loud, medium, soft]',
        choices: [ 'loud', 'medium', 'soft' ],
        defaultValue: 'medium'
    })
    .handler(function (args, opts) {
        if (opts.volume === 'loud') {
            args = args.map(function(x) { return x.toUpperCase() })
        } else if (opts.volume === 'soft') {
            args = args.map(function(x) { return x.toLowerCase() })
        }
        console.log.apply(null, args)
    })

module.exports = cli

if (require.main

In your terminal:

~$ chmod u+x ./easy.js
~$ ./easy.js help
~$ ./easy.js help say
~$ ./easy.js say hi there
~$ ./easy.js say -v loud hey out there
~$ ./easy.js --repl
> help
> say hi
> exit
~$

Summary

  • Simple, chaining interface for easy and clear cli specification
  • Batteries included!
    • Auto-generated help/usage output
    • Default commands & options provided (help, exit, --version, --help)
    • Robust validation of commands, options, and argument values
    • Auto-included repl allows you to run your cli as an interactive repl

API

CLI Metadata

Options

Sub-Commands