execute-me
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

Execute Me npm version Build Status

Automatically generate command line interfaces from JavaScript functions.

Installation

npm install execute-me --save
 

Usage

const { executeMe } = require('execute-me');
 
function eatFood(count=5, food, weight, check) {
  /**
   * A function named eatFood.
   *
   * @version 0.1.0-beta3
   * @param {integer} count - number of food
   * @param {string} food - what for dinner
   * @param {float} weight - how much would you like to eat
   * @param {boolean} check - yes?
   */
  console.log(`${count} ${food} weigh ${weight} kilograms. ${check ? '' : 'x'}`)
}
 
executeMe(eatFood);
 
$ ./example/eatFood.js --food "rice balls" -w 2.2 --check
5 rice balls weigh 2.2 kilograms. √
 
$ ./example/eatFood.js --version
0.1.0-beta3
 
$ ./example/eatFood.js -h
Usage: 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?

You should not uglify the entrance function because it depends on toString method of functions.

License

MIT

Dependencies (4)

Dev Dependencies (17)

Package Sidebar

Install

npm i execute-me

Weekly Downloads

31

Version

0.2.0

License

MIT

Unpacked Size

19.6 kB

Total Files

15

Last publish

Collaborators

  • means88