mirror of
https://github.com/flynx/argv.js.git
synced 2025-12-19 10:01:41 +00:00
docs...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
ece1a86d1c
commit
10a35299c2
50
README.md
50
README.md
@ -63,7 +63,53 @@ Now for the code
|
|||||||
var argv = require('ig-argv')
|
var argv = require('ig-argv')
|
||||||
|
|
||||||
var parser = argv.Parser({
|
var parser = argv.Parser({
|
||||||
// XXX
|
// basic/quick option...
|
||||||
|
'-b': '-basic',
|
||||||
|
'-basic': function(){
|
||||||
|
// ...
|
||||||
|
},
|
||||||
|
|
||||||
|
// full option settings...
|
||||||
|
'-f': '-full',
|
||||||
|
'-full': {
|
||||||
|
doc: 'Option help',
|
||||||
|
// option value to be displayed in help (optional)
|
||||||
|
arg: 'VALUE',
|
||||||
|
|
||||||
|
// value key (optional)
|
||||||
|
// NOTE: if .handler(..) is defined this is ignored.
|
||||||
|
key: 'fullValue',
|
||||||
|
// envioroment value (optional)
|
||||||
|
env: 'VALUE',
|
||||||
|
// default value (optional)
|
||||||
|
default: 123,
|
||||||
|
// required status (optional)
|
||||||
|
required: true,
|
||||||
|
|
||||||
|
// handler (optional)
|
||||||
|
handler: function(opts, key, value){
|
||||||
|
// ...
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
// command...
|
||||||
|
// NOTE: the only difference between an option and a command is
|
||||||
|
// the prefix ('-' vs. '@') that determines how it is parsed,
|
||||||
|
// otherwise they are identical and can alias each other...
|
||||||
|
'@cmd', '@command',
|
||||||
|
'@command': {
|
||||||
|
// ...
|
||||||
|
},
|
||||||
|
|
||||||
|
// example command-option alias...
|
||||||
|
'@help': '-help',
|
||||||
|
|
||||||
|
// nested parser...
|
||||||
|
'@nested': argv.Parser({
|
||||||
|
// ...
|
||||||
|
}).then(function(){
|
||||||
|
// ...
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
.then(function(){
|
.then(function(){
|
||||||
// XXX
|
// XXX
|
||||||
@ -79,6 +125,8 @@ This will create a parser that supports the folowing:
|
|||||||
$ ./script.js --help
|
$ ./script.js --help
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user