diff --git a/README.md b/README.md index 07890f6..f0ae929 100644 --- a/README.md +++ b/README.md @@ -71,29 +71,29 @@ This code is an evolution of that parser. - [`-h` / `--help`](#-h----help) - [Value placeholders](#value-placeholders) - [Automatically defined values](#automatically-defined-values) - - [`.doc`](#doc) - - [`.usage`](#usage) - - [`.version`](#version) - - [`.license`](#license) - - [`.examples`](#examples) - - [`.footer`](#footer) + - [`.doc`](#parserdoc) + - [`.usage`](#parserusage) + - [`.version`](#parserversion) + - [`.license`](#parserlicense) + - [`.examples`](#parserexamples) + - [`.footer`](#parserfooter) - [More control over help...](#more-control-over-help) - [Nested parsers](#nested-parsers) - [Components and API](#components-and-api) - [`THEN`, `STOP` and `ERROR`](#then-stop-and-error) - [`Parser(..)`](#parser) - - [`.then(..)`](#then) - - [`.stop(..)`](#stop) - - [`.error(..)`](#error) - - [`.off(..)`](#off) + - [`.then(..)`](#parserthen) + - [`.stop(..)`](#parserstop) + - [`.error(..)`](#parsererror) + - [`.off(..)`](#parseroff) - [`(..)`](#parser-1) - [Advanced parser API](#advanced-parser-api) - - [`.print(..)` / `.printError(..)`](#print--printerror) - - [`.handlerDefault(..)`](#handlerdefault) - - [`.handleArgumentValue(..)`](#handleargumentvalue) - - [`.handleErrorExit(..)`](#handleerrorexit) + - [`.print(..)` / `.printError(..)`](#parserprint--parserprinterror) + - [`.handlerDefault(..)`](#parserhandlerdefault) + - [`.handleArgumentValue(..)`](#parserhandleargumentvalue) + - [`.handleErrorExit(..)`](#parserhandleerrorexit) - [More...](#more) - - [License](#license-1) + - [License](#license) ## Installation @@ -137,6 +137,7 @@ XXX make this a set of practical options and leave the attr explanation to later ```javascript var parser = argv.Parser({ // doc sections... + varsion: '0.0.1', doc: 'Example script options', author: 'John Smith ', footer: 'Written by $AUTHOR ($VERSION / $LICENSE).', @@ -415,7 +416,7 @@ not given. Stop processing further options. This can be used to terminate nested parsers or to stop option processing -in the root parser to handle the rest of the options in `.then(..)`, +in the root parser to handle the rest of the options in `.then(..)`, for example. @@ -481,7 +482,7 @@ These values are set by the parser just before parsing starts: These will be overwritten when the parser is called. -##### `.doc` +##### `.doc` Script documentation. .doc = | @@ -489,7 +490,7 @@ Script documentation. Default value: `undefined` -##### `.usage` +##### `.usage` Basic usage hint. .usage = | | undefined @@ -497,7 +498,7 @@ Basic usage hint. Default value: `"$SCRIPTNAME [OPTIONS]"` -##### `.version` +##### `.version` Version number. .usage = | | undefined @@ -507,7 +508,7 @@ If this is not defined `-version` will print `"0.0.0"`. Default value: `undefined` -##### `.license` +##### `.license` Short license information. .usage = | | undefined @@ -515,7 +516,7 @@ Short license information. Default value: `undefined` -##### `.examples` +##### `.examples` .usage = | | | undefined @@ -529,7 +530,7 @@ Example list format: Default value: `undefined` -##### `.footer` +##### `.footer` Aditional information. .footer = | | undefined @@ -539,7 +540,7 @@ Default value: `undefined` ##### More control over help... -For more info on help formatting see `.help*` attributes in the [source](./argv.js). +For more info on help formatting see `.help*` attributes in the [source](./argv.js). ### Nested parsers @@ -602,10 +603,10 @@ See [lang.js](./lang.js) for more fun with argv and programming languages ;) Values that if returned by option/command handlers can control the parse flow. -- `THEN` – Stop parsing and call `.then(..)` callbacks. -- `STOP` – Stop parsing and call `.stop(..)` callbacks, - skipping `.then(..)`. -- `ERROR` – Stop parsing, call `.error(..)` callbacks and +- `THEN` – Stop parsing and call `.then(..)` callbacks. +- `STOP` – Stop parsing and call `.stop(..)` callbacks, + skipping `.then(..)`. +- `ERROR` – Stop parsing, call `.error(..)` callbacks and exit with an error. ### `Parser(..)` @@ -618,7 +619,7 @@ Parser() See [`(..)`](#parser-1) for more info. -#### `.then(..)` +#### `.then(..)` Add callback to `then` "event". ``` @@ -634,7 +635,7 @@ callback(, , ) `then` is triggered when parsing is done or stopped from an option handler by returning `THEN`. -#### `.stop(..)` +#### `.stop(..)` Add callback to `stop` "event". ``` @@ -649,7 +650,7 @@ callback(, ) `stop` is triggered when a handler returns `STOP`. -#### `.error(..)` +#### `.error(..)` Add callback to `error` "event". ``` @@ -665,7 +666,7 @@ callback(, , ) `error` is triggered when a handler returns `ERROR`. -#### `.off(..)` +#### `.off(..)` Remove callback from "event". ``` @@ -704,11 +705,11 @@ its head. ## Advanced parser API -### `.print(..)` / `.printError(..)` +### `.print(..)` / `.printError(..)` -Handle how `Parser(..)` prints things. +Handle how `` prints things. -`.print(..)` and `.printError(..)` are very similar but handle different +`.print(..)` and `.printError(..)` are very similar but handle different cases, similar to `console.log(..)` and `console.error(..)` ``` .print(...) @@ -727,20 +728,21 @@ Both support callback binding: -> ``` -Both `.print(..)` and `.printError(..)` can safely be overloaded if the -callback feature is not going to be used by the user – the print -callbacks are not used internally. -For full callback support see: `extra.afterCallback(..)` in [argv.js](./argv.js). +Both `.print(..)` and `.printError(..)` can safely be +overloaded if the callback feature is not going to be used by the user +– the print callbacks are not used internally. + +For full callback API see: `extra.afterCallback(..)` in [argv.js](./argv.js). -### `.handlerDefault(..)` +### `.handlerDefault(..)` Called when `