nomnom
Advanced tools
Comparing version 1.6.2 to 1.7.0
@@ -463,2 +463,6 @@ var _ = require("underscore"), | ||
if (option.transform) { | ||
value = option.transform(value); | ||
} | ||
var name = option.name || arg; | ||
@@ -465,0 +469,0 @@ if (option.choices && option.choices.indexOf(value) == -1) { |
{ | ||
"name": "nomnom", | ||
"description": "Option parser with generated usage and commands", | ||
"version": "1.6.2", | ||
"version": "1.7.0", | ||
"author": "Heather Arthur <fayearthur@gmail.com>", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -176,2 +176,6 @@ # nomnom | ||
#### type | ||
If you don't want the option JSON-parsed, specify type `"string"`. | ||
#### callback | ||
@@ -184,4 +188,5 @@ | ||
callback: function(count) { | ||
if (count != parseInt(count)) | ||
if (count != parseInt(count)) { | ||
return "count must be an integer"; | ||
} | ||
} | ||
@@ -211,6 +216,15 @@ }) | ||
#### type | ||
#### transform | ||
If you don't want the option JSON-parsed, specify type `"string"`. | ||
A function that takes the value of the option as entered and returns a new value that will be seen as the value of the option. | ||
```javascript | ||
nomnom.option('date', { | ||
abbr: 'd', | ||
transform: function(timestamp) { | ||
return new Date(timestamp); | ||
} | ||
}) | ||
``` | ||
#### hidden | ||
@@ -217,0 +231,0 @@ |
36374
14
1014
322