1.0.1 • Published 9 years ago

flagman v1.0.1

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

flagman.js

Parse command flags and generate usage text.

Install: npm install flagman

Test: npm test

Example usage:

var args = require('flagman')({
    // Define flags here
    '--flag1': {
        'default': 'Default',
        // args.flag1 will be 'Default' if the argument is not valid.
        'validOptions': ['Default', 'NotDefault']
    },
    '-bool': {
        // Empty validOptions means the flag is true/false depending on presence in args
        'validOptions': []
    },
    '--date': {
        'default': '2014-09-10',
        // Validate on regular expression
        'validRegex': /\d{4}-\d{2}-\d{2}/
    }
});

Help text for the above:

Options:
  --flag1   Default: Default. Valid: Default,NotDefault
  -bool
  --date    Default: 2014-09-10. Matches: /\d{4}-\d{2}-\d{2}/
1.0.1

9 years ago

1.0.0

9 years ago