From edaefa191a744f77b4e01bd60b602e5b44e735ba Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 17 Jul 2020 00:01:47 +0300 Subject: [PATCH] docs... Signed-off-by: Alex A. Naanou --- README.md | 55 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 803cd95..743777c 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,12 @@ This code is an evolution of that parser. - Hooks for dynamic option/command handling - Customizable error and stop condition handling +## Planned Features + +- Run `-` scripts +- Multiple option prefix support + + @@ -43,6 +49,7 @@ This code is an evolution of that parser. - [argv.js](#argvjs) - [Motivation](#motivation) - [Features](#features) + - [Planned Features](#planned-features) - [Contents](#contents) - [Installation](#installation) - [Basic usage](#basic-usage) @@ -102,25 +109,54 @@ Now for the code var argv = require('ig-argv') var parser = argv.Parser({ - // basic/quick option... + // option definitions... + // ... + }) + .then(function(){ + // things to do after the options are handled... + // ... + }) + +// run the parser... +if(__filename == require.main){ + parser(process.argv) } +``` + +Option definitions in a bit more detail +```javascript +var parser = argv.Parser({ + // basic/quick-n-dirty option... '-b': '-basic', - '-basic': function(){ + '-basic': function(opts, key, value){ // ... }, + // basic value-getter option... + '-value': { + doc: 'Value option', + arg: 'X | x', + }, + // full option settings... '-f': '-full', '-full': { + // option doc (optional) doc: 'Option help', + // option value to be displayed in help (optional) // NOTE: "attr" is used as a key to set the value if .handler // was not defined and is ingored in all other cases... arg: 'VALUE | attr', + // value type handler (optional) + type: 'int', + // envioroment value (optional) env: 'VALUE', + // default value (optional) default: 123, + // required status (optional) required: false, @@ -144,18 +180,11 @@ var parser = argv.Parser({ // nested parser... '@nested': argv.Parser({ - // ... - }).then(function(){ - // ... - }), + // ... + }).then(function(){ + // ... + }), }) - .then(function(){ - // XXX - }) - -// run the parser only if script.js is run directly... -if(__filename == require.main){ - parser(process.argv) } ``` This will create a parser that supports the folowing: