diff --git a/README.md b/README.md index acddceb..35b5849 100644 --- a/README.md +++ b/README.md @@ -218,20 +218,33 @@ for example: These, if encountered, simply assign a value to an attribute on the parsed object. -If no value is given `true` is assigned to indicate that the option/command is -present in the command-line. +Any option/command can be passed a value, either explicitly (e.g. `-opt=123`) or +implicitly by first setting `.arg` (see examples below) and and then passing `-opt 123`. + +If no value is given `true` is assigned to option attribute on the parsed object +to indicate that the option/command is present in the command-line. + +Note that repeating a basic option/command will overwrite the previous value +unless `.collect` is set (see `-push` example below). + +Note that in general case option order in the command-line is not critical, +but option context can matter (see: [Active options/commands](#active-optionscommands) and [Nested parsers](#nested-parsers)) ```javascript '-bool': { - doc: 'if given set .bool to true' }, + doc: 'if given, set .bool to true' }, // option with a value... '-value': { doc: 'set .x to X', - // 'X' (VALUE) is used for -help while 'x' (key) is where the - // value will be written... + // 'X' (i.e. VALUE) is used to indicate the option value in -help + // while 'x' (key) is the attribute where the value will be written... + // + // NOTE: if no .arg is set option attribute name is used. + // + // See the first example in "Calling the script" section below for output. arg: 'X | x', // the value is optional by default but we can make it required... @@ -240,6 +253,9 @@ present in the command-line. // setup an alias -r -> -required + // + // NOTE: aliases are used only for referencing, all naming is done via the + // actual option/command name. '-r': '-required', // a required option... @@ -257,7 +273,7 @@ present in the command-line. }, - '-int': { + '-i': { doc: 'pass an integer value', // NOTE: if not key is given the VALUE name is used as a key, so the @@ -282,7 +298,7 @@ present in the command-line. '-home': { doc: 'set home path', - arg: 'HOME | home', + arg: 'PATH | home_path', // get the default value from the environment variable $HOME... env: 'HOME', @@ -300,6 +316,10 @@ present in the command-line. }, ``` +For more info on available `.type` and `.collect` handlers see: +[`