From 02ecbb10989f1644ad1a020399ea0bf2332fc3e2 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 4 Jul 2020 21:48:25 +0300 Subject: [PATCH] docs... Signed-off-by: Alex A. Naanou --- README.md | 297 +++++++++++++++++++++++++++++++++++++++++++++++++++++- argv.js | 36 ++++--- 2 files changed, 317 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 9e54a41..e7fa941 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,46 @@ This code is an evolution of that parser. +## Contents +- [argv.js](#argvjs) + - [Motivation](#motivation) + - [Features](#features) + - [Contents](#contents) + - [Installation](#installation) + - [Basic usage](#basic-usage) + - [Configuration](#configuration) + - [Options, commands and aliases](#options-commands-and-aliases) + - [Help](#help) + - [Value placeholders](#value-placeholders) + - [Automatically defined values](#automatically-defined-values) + - [`.doc`](#doc) + - [`.usage`](#usage) + - [`.version`](#version) + - [`.license`](#license) + - [`.examples`](#examples) + - [`.footer`](#footer) + - [Help formatting](#help-formatting) + - [`.helpColumnOffset`](#helpcolumnoffset) + - [`.helpColumnPrefix`](#helpcolumnprefix) + - [`.helpArgumentSeparator`](#helpargumentseparator) + - [`.helpValueSeparator`](#helpvalueseparator) + - [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) + - [`(..)`](#parser-1) + - [Advanced parser API](#advanced-parser-api) + - [`.print(..)` / `.printError(..)`](#print--printerror) + - [`.handlerDefault(..)`](#handlerdefault) + - [`.handleArgument(..)`](#handleargument) + - [`.handleArgumentValue(..)`](#handleargumentvalue) + - [`.handleErrorExit(..)`](#handleerrorexit) + - [License](#license-1) + ## Installation @@ -84,7 +124,7 @@ var parser = argv.Parser({ // default value (optional) default: 123, // required status (optional) - required: true, + required: false, // handler (optional) handler: function(opts, key, value){ @@ -123,10 +163,263 @@ if(__filename == require.main){ This will create a parser that supports the folowing: ```shell $ ./script.js --help + +$ ./script.js command + +$ ./script.js nested -h + +$ ./script.js -fb + ``` ## Configuration +This sections lists attributes and methods designed to be set/modified in +`` passed to `Parser(..)`. + +Note that these attributes are the same attributes inherited by `` +(parser instance) and are simply merged into the new instance created by +`Parser(..)`, this there are no restrictions on what attributes/methods +can be overloaded in this way but care must be taken when overloading +elements that were not designed to be overloaded. + +```javascript +var parser = Parser({ + +}) +``` + +### Options, commands and aliases + +### Help + +`Parser` defines a default help generator via the `-h` and `-help` options. + +By default `-help` will output in the following format: +``` + + + + +Options: + + - + (, , ) + ... + +Dynamic options: + ... + +Commands: + ... + +Examples: + ... + +