0.2.0 • Published 6 years ago

execute-me v0.2.0

Weekly downloads
10
License
MIT
Repository
github
Last release
6 years ago

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

0.2.0

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago