Xcm
XCM or Xcommand is a Node.js CLI tool builder.
installation
$ yarn add xcm$ npm install xcm --save # Use npm
Usage
#!/usr/bin/env node //// cli.js// ; const command = 'xcm'; command action processstdout action processstdout command action processstdout command action processstdout action processstdout command // Go!command
$ ./cli.js init # init! $ ./cli.js init something # init something! $ ./cli.js opt # { hello: "world" } $ ./cli.js opt -y --hello="Node.js" # { y: true, hello: "Node.js" } $ ./cli.js a b c d e # abcde! $ ./cli.js A B C D E # ABCDE! $ ./cli.js help # <show help>
APIs
constructor
;const commnad = "cli.js";commandaction processstdout;
$ ./cli.js # init!
command.sub(phrase:string)
sub
define sub command.
;"cli.js"; action processstdout ;
$ ./cli.js hello # hello!
command.option(phrase, options)
option
defines acceptable options. This will be used with help
.
;"cli.js"; action processstdout ;
$ ./cli.js --word=hello # say hello!
command.action(callback)
action callback
command.describe(description:string)
describe
defines description for the command. This will be used with help
.
command.super()
command.parse()
parse
starts parse given environment and execution of each command.
command.parseAsync()
Development
$ git clone git@github.com:kamataryo/xcm.git$ cd xcm$ yarn # or npm install