1.11.0 • Published 2 years ago

chickpea v1.11.0

Weekly downloads
3
License
ISC
Repository
github
Last release
2 years ago

chickpea

A little bean for parsing command line arguments without any surprises, at all.

Install

npm i chickpea

Example

#!/usr/bin/env node

const chickpea = require('chickpea');
const program = require('./index.js');

const configuration = { input: 'Input PNG' };
const options = chickpea(configuration);

program(options)

Usage

#!/usr/bin/env node

const chickpea = require('chickpea');

const pizzaOrder = chickpea({

  pepper_flag: 'Add peppers.',
  pineapple_flag: 'Add pineapple.',
  bbqSauce_flag: 'Add bbq sauce.',
  cheese: 'Add the specified type of cheese: --cheese gorgonzola',
  firstName: 'First name.',
  lastName: 'Last name.',

});

console.log('Cheese Type:', pizzaOrder.cheese);
console.log('BBQ Sauce:', pizzaOrder.bbqSauce?'yes':'no');

Execute

$ ./example.js --cheese "Super Stinky" --bbq-sauce

Result

Cheese Type: Super Stinky
BBQ Sauce: yes

Extras

When executing with -h flag you get the following

$ ./example.js -h


  Usage: example [options]

  Options:

    -V, --version           output the version number
    -p,--pepper             Add peppers.
    -i,--pineapple          Add pineapple.
    -b,--bbq-sauce          Add bbq sauce.
    -c,--cheese [text]      Add the specified type of cheese: --cheese gorgonzola
    -f,--first-name [text]  First name.
    -l,--last-name [text]   Last name.
    -h, --help              output usage information
1.11.0

2 years ago

1.10.0

3 years ago

1.9.0

5 years ago

1.8.0

5 years ago

1.7.0

5 years ago

1.6.0

5 years ago

1.5.0

6 years ago

1.2.0

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.1.0

6 years ago