This repository has been archived by the owner on Sep 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
97 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,32 @@ | |||
var nomnom = require("../lib/nomnom"), | |||
assert = require('assert'); | |||
|
|||
var opts = { | |||
version: { | |||
string: '--version', | |||
callback: function() { | |||
assert.ok(true, "called version callback"); | |||
} | |||
}, | |||
date: { | |||
string: '-d YYYY-MM-DD, --date=YYYY-MM-DD', | |||
callback: function(date) { | |||
assert.equal(date, "2010-02-03", "date should match value") | |||
} | |||
} | |||
} | |||
|
|||
var options = nomnom().opts(opts).parseArgs(["--version", "--date=2010-02-03"]); | |||
|
|||
/* // exits process | |||
nomnom().opts({ | |||
version: { | |||
string: '--version', | |||
callback: function() { | |||
return "called version callback"; | |||
} | |||
} | |||
}).parseArgs(["--version"]); | |||
assert.ok(false, "should have exited when --version specified"); | |||
*/ |
With this change this is a complete superset and improvement of the functionality in the node optparse port.