Browse files

readme mistakes

  • Loading branch information...
1 parent 9db84a8 commit 80a9cde33542ffc5fe6855f853c7c8ef7aab1740 @harthur committed Apr 15, 2011
Showing with 12 additions and 5 deletions.
  1. +12 −5 README.md
View
17 README.md
@@ -21,6 +21,7 @@ nomnom is an option parser for node and CommonJS. It just noms your args and giv
// do stuff
You don't even have to specify anything if you don't want to:
+
var options = nomnom.parseArgs();
var url = options[0]; // get the first positional arg
@@ -29,11 +30,11 @@ You don't even have to specify anything if you don't want to:
# Install
for [node.js](http://nodejs.org/) and [npm](http://github.com/isaacs/npm):
+
npm install nomnom
# Commands
-Nomnom supports command-based interfaces, e.g. with git: `git add -p` and
-`git rebase -i` where `add` and `rebase` are the commands:
+Nomnom supports command-based interfaces, e.g. with git: `git add -p` and `git rebase -i` where `add` and `rebase` are the commands:
var parser = nomnom();
@@ -62,32 +63,36 @@ Nomnom supports command-based interfaces, e.g. with git: `git add -p` and
# More Details
By default, nomnom parses [node](http://nodejs.org/)'s `process.argv`. You can also pass in the args:
+
var options = nomnom.parseArgs(opts, { argv: ["-xvf", "--atomic=true"] })
Values are JSON parsed, so `--debug=true --count=3 --file=log.txt` would give you:
+
{ debug: true,
count: 3,
file: "log.txt"
}
### positional args
All parsed arguments that don't fit the `-a` or `--atomic` format and aren't attached to an option are positional and can be matched on via the `position`:
+
var opts = {
filename: {
position: 0,
help: 'file to edit'
}
};
- var options = nomnom(opts).parseArgs();
+ var options = nomnom.parseArgs(opts);
sys.puts(options.filename);
### printing usage
Nomnom prints out a usage message if `--help` or `-h` is an argument. You can disable this with the `printHelp` flag and specify the printing function with `printFunc`:
- nomnom(opts, { printHelp: false }).parseArgs();
+ nomnom.parseArgs(opts, { printHelp: false });
Usage for these options in `test.js`:
+
var options = {
command: {
position: 0,
@@ -104,6 +109,7 @@ Usage for these options in `test.js`:
}
...would look like this:
+
Usage: node test.js <command> [options]
<command> either 'test', 'run', or 'xpi'
@@ -113,4 +119,5 @@ Usage for these options in `test.js`:
-d, --debug use debug mode
Nomnom can't detect the alias used to run your script. You can use the `script` option to print the correct name instead of e.g. `node test.js`:
- nomnom(opts, { script : "test" });
+
+ nomnom.parseArgs(opts, { script : "test" });

0 comments on commit 80a9cde

Please sign in to comment.