substack/node-optimist — pull request #70 by miningold (2012-09-25 22:30:23+00:00)
Title: Implies: Conditional demands

Implemented the logical operator 'imply' or '->' for conditional requirements.

An example of x -> y:

```javascript
var argv = require('optimist')
.usage('Usage: $0 -x [num] -y [num]')
.implies('x', 'y')
.argv;

if (argv.x) {
console.log(argv.x / argv.y);
}
```
y may or may not exist, but if x exists then y must exist.

error messages for this look like:
```
Implications failed:
x -> y
```

implies() excepts key value pairs or an object with key and value pairs. Implies also allows for if x then not y by doing: ```.implies('x', '--no-y')``` and vice versa. Any numbers used for the key or value will represent the number arguments in required in argv._

Note: a clearer name for this might be conditional, I left it as implies because it corresponds with the mathematical term.

Note: For reference, x->y is equivalent to: !x || y (not x or y)

Example runs of above code:
```
node app.js
node app.js -x 10 --- Error
node app.js -y 11
node app.js -x 10 -y 11
```

Implies can be a solution to this [issue](https://github.com/substack/node-optimist/issues/52) and this [issue](https://github.com/substack/node-optimist/issues/51)