Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Tiny command line options parser for node.js in CoffeeScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
lib
src
.npmignore
LICENSE.txt
README.md
package.json

README.md

parsy NPM version

Tiny command line options parser for node.js in CoffeeScript.

Installation

$ npm install parsy

Usage

It automatically parse process.argv so you just have to "subscribe" for the options you want.

Example

var parsy = require('parsy');

// register options
parsy
  // no options passed
  .on('', function () {
    console.log('Enter option or -h for help');
  })
  // script -h
  .on('-h', function (option, value) {
    console.log('Hey give me some help here');
  })
  // script --file file1.js
  .on('--file', function (option, value) {
    // if no files passed show a message
    if (!value) {
      console.log('Usage: --file <file1.js file2.js>');

    // simple check if the value passed to --file are js files
    } else if (!/\.js$/.test(value)) {
      console.log('Only .js files can be passed using the --file option!');
    }
  });

See parsy options object with all options passed

console.log(parsy.options);
// example
// { node: 'script.js', '-h': true, '--file': 'file1.js' }

License

See LICENSE.txt

Something went wrong with that request. Please try again.