Skip to content
This repository has been archived by the owner on Jun 24, 2019. It is now read-only.

l3laze/cmdo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cmdo

A small CLI parser inspired by https://github.com/node-js-libs/cli. Can also auto-generate a help page in a style similar to man or usage.

Usage

const cmdo = require('cmdo')

// Format = longName: [ 'shortName', 'description', 'type', 'default' ]
const cli = {
  stringOption: [ 's', 'An option', 'string', 'defaultValue' ],
  numberOption: [ 'n', 'An option', 'number', 1111111 ],
  booleanOption: [ 'b', 'An option', 'boolean', false ]
}

const options = cmdo.parse(cli)
const man = cmdo.man(cli)
const help = cmdo.help(cli)

cmdo.parse(options)

Returns an object filled with the options from process.argv mapped to those from options, like:

{
  stringOption: 'defaultValue',
  numberOption: 8
}

cmdo.man(options)

Returns a man page-like string for the cli options.

cmdo.help(options)

Returns a usage-like string for the cli options.

About

A small cli parser.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published