Automatically generate command line interfaces from JavaScript functions.
Installation
npm install execute-me --save
Usage
const executeMe = ; { /** * A function named eatFood. * * @version 0.1.0-beta3 * @param * @param * @param * @param */ console} ;
$ ./example/eatFood.js --food "rice balls" -w 2.2 --check5 rice balls weigh 2.2 kilograms. √
$ ./example/eatFood.js --version0.1.0-beta3
$ ./example/eatFood.js -hUsage: eatFood [options] A function named eatFood. Options: -V, --version output the version number -c, --count <count> number of food (default: 5) -f, --food <food> what for dinner -w, --weight <weight> how much would you like to eat --check yes? -h, --help output usage information
Supported Types
Only number, string and boolean is supported. Union types are not supported yet.
integer
alias:
- int
- integer
- Int
- Integer
float
alias:
- float
- Float
- number
- Number
string
alias:
- str
- string
- String
boolean
alias:
- bool
- boolean
- Boolean
any(boolean or string)
alias:
- any
How does it work?
- Get the source code of the function by
fn.toString()
- Parse the argument list with @babel/parser and JSDoc with Doctrine
- Create CLI with Commander.js
You should not uglify the entrance function because it depends on toString
method of functions.
License
MIT