<commit_before>> 
> # deprecation notice
> 
> The original author's `nomnom` is deprecated; this (and other) forks is not: we continue to update this library.
> 
> When you are unsure about using this library's fork (or others), you may wish to check out https://github.com/tj/commander.js, which should have most, if not all of the capability that nomnom has. Thank you!
> 

# nomnom


[![build status](https://secure.travis-ci.org/GerHobbelt/nomnom.png)](https://travis-ci.org/search/nomnom)


nomnom is an option parser for node. It noms your args and gives them back to you in a hash.

```javascript
var opts = require("nomnom")
   .option('debug', {
      abbr: 'd',
      flag: true,
      help: 'Print debugging info'
   })
   .option('config', {
      abbr: 'c',
      default: 'config.json',
      help: 'JSON file with tests to run'
   })
   .option('version', {
      flag: true,
      help: 'print version and exit',
      callback: function() {
         return "version 1.2.4";
      }
   })
   .parse();

if (opts.debug)
   // do stuff
```

You don't have to specify anything if you don't want to:

```javascript
var opts = require("nomnom").parse();

var url = opts[0];     // get the first positional arg
var file = opts.file   // see if --file was specified
var verbose = opts.v   // see if -v was specified
var extras = opts._    // get an array of the unmatched, positional args
```


# Install

for [node.js](http://nodejs.org/) and [npm](http://github.com/isaacs/npm):

	npm install nomnom


# More Details

Nomnom supports args like `-d`, `--debug`, `--no-debug`, `--file=test.txt`, `--file test.txt`, `-f test.txt`, `-xvf`, and positionals. Positionals are arguments that don't fit the `-a` or `--atomic` format and aren't attached to an option.

Values are JSON parsed, so `--debug=true --count=3 --file=log.txt` would give you:

```
{
   "debug": true,
   "count": 3,
   "file": "log.txt"
}
```


# Commands

Nomnom supports command-based interfaces (e.g. with git: `git add -p` and `git rebase -i` where `add` and `rebase` are the commands):

```javascript
var parser = require("nomnom");

parser.command('browser')
   .callback(function(opts) {
      runBrowser(opts.url);
   })
   .help("run browser tests");

parser.command('sanity')
   .option('outfile', {
      abbr: 'o',
      help: "file to write results to"
   })
   .option('config', {
      abbr: 'c',
      default: 'config.json',
      help: "json manifest of tests to run"
   })
   .callback(function(opts) {
      runSanity(opts.filename);
   })
   .help("run the sanity tests")

parser.parse();
```

Each command generates its own usage message when `-h` or `--help` is specified with the command.


# Usage

Nomnom prints out a usage message if `--help` or `-h` is an argument. If no commands are called (the script is simply run without arguments), `-h` will be called automatically unless you've disabled this feature using the `.autoShowUsage(false)` API call. 

Usage for these options in `test.js`:

```javascript
var opts = require("nomnom")
   .script("runtests")
   .options({
      path: {
         position: 0,
         help: "Test file to run",
         list: true<commit_msg>update README: nomnom should be `@gerhobbelt/nomnom` as that's the name of my active fork.<commit_after>> 
> # deprecation notice
> 
> The original author's `nomnom` is deprecated; this (and other) forks is not: we continue to update this library.
> 
> When you are unsure about using this library's fork (or others), you may wish to check out https://github.com/tj/commander.js, which should have most, if not all of the capability that nomnom has. Thank you!
> 

# nomnom


[![build status](https://secure.travis-ci.org/GerHobbelt/nomnom.png)](https://travis-ci.org/search/nomnom)


nomnom is an option parser for node. It noms your args and gives them back to you in a hash.

```javascript
var opts = require("@gerhobbelt/nomnom")
   .option('debug', {
      abbr: 'd',
      flag: true,
      help: 'Print debugging info'
   })
   .option('config', {
      abbr: 'c',
      default: 'config.json',
      help: 'JSON file with tests to run'
   })
   .option('version', {
      flag: true,
      help: 'print version and exit',
      callback: function() {
         return "version 1.2.4";
      }
   })
   .parse();

if (opts.debug)
   // do stuff
```

You don't have to specify anything if you don't want to:

```javascript
var opts = require("@gerhobbelt/nomnom").parse();

var url = opts[0];     // get the first positional arg
var file = opts.file   // see if --file was specified
var verbose = opts.v   // see if -v was specified
var extras = opts._    // get an array of the unmatched, positional args
```


# Install

for [node.js](http://nodejs.org/) and [npm](http://github.com/isaacs/npm):

	npm install @gerhobbelt/nomnom


# More Details

Nomnom supports args like `-d`, `--debug`, `--no-debug`, `--file=test.txt`, `--file test.txt`, `-f test.txt`, `-xvf`, and positionals. Positionals are arguments that don't fit the `-a` or `--atomic` format and aren't attached to an option.

Values are JSON parsed, so `--debug=true --count=3 --file=log.txt` would give you:

```
{
   "debug": true,
   "count": 3,
   "file": "log.txt"
}
```


# Commands

Nomnom supports command-based interfaces (e.g. with git: `git add -p` and `git rebase -i` where `add` and `rebase` are the commands):

```javascript
var parser = require("@gerhobbelt/nomnom");

parser.command('browser')
   .callback(function(opts) {
      runBrowser(opts.url);
   })
   .help("run browser tests");

parser.command('sanity')
   .option('outfile', {
      abbr: 'o',
      help: "file to write results to"
   })
   .option('config', {
      abbr: 'c',
      default: 'config.json',
      help: "json manifest of tests to run"
   })
   .callback(function(opts) {
      runSanity(opts.filename);
   })
   .help("run the sanity tests")

parser.parse();
```

Each command generates its own usage message when `-h` or `--help` is specified with the command.


# Usage

Nomnom prints out a usage message if `--help` or `-h` is an argument. If no commands are called (the script is simply run without arguments), `-h` will be called automatically unless you've disabled this feature using the `.autoShowUsage(false)` API call. 

Usage for these options in `test.js`:

```javascript
var opts = require("@gerhobbelt/nomnom")
   .script("runtests")
   .options({
      path: {
         position: 0,
         help: "Test file to run",
         list: true
{'fraction_non_alphanumeric': 0.144528243804833, 'fraction_numerical': 0.0021548406957057104, 'mean_word_length': 3.023529411764706, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6377608', 'n_tokens_mistral': 2150, 'n_tokens_neox': 2058, 'n_words': 750}