From 2ecab5eb1cb76df4023742d51e86f41cddb5628e Mon Sep 17 00:00:00 2001 From: Alhadis Date: Tue, 26 Feb 2019 04:32:41 +1100 Subject: [PATCH] Add terse documentation for each new added setting --- CHANGELOG.md | 7 +++++++ docs/advanced-settings.md | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae3c439..a6ea18e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,15 @@ This project honours [Semantic Versioning](http://semver.org/). [Staged] ------------------------------------------------------------------------ * __Added:__ Ability to extract option-lists from strings +* __Added:__ Setting to [disable mixed-order][6] option/argument lists +* __Added:__ Setting to [throw an error][7] for unrecognised options +* __Added:__ Support for [terminating][8] options using a double-dash * __Fixed:__ Options array being modified by reference + [6]: ./docs/advanced-settings.md#nomixedorder + [7]: ./docs/advanced-settings.md#noundefined + [8]: ./docs/advanced-settings.md#terminator + [v1.1.3] ------------------------------------------------------------------------ diff --git a/docs/advanced-settings.md b/docs/advanced-settings.md index b1744cb..00e4018 100644 --- a/docs/advanced-settings.md +++ b/docs/advanced-settings.md @@ -11,7 +11,10 @@ The supported settings and their default values are: ignoreEquals: false, noAliasPropagation: false, noBundling: false, - noCamelCase: false + noCamelCase: false, + noMixedOrder: false, + noUndefined: false, + terminator: null, }); @@ -196,3 +199,31 @@ If you prefer to keep names verbatim, just set `noCamelCase` to any truthy value $ program --set-size -> options["set-size"] + + + +noMixedOrder +------------ + +Terminate option-processing at the first non-option: + + $ program --global outdated # This would work + $ program outdated --global # This would not + +Normally, the whole argument list is traversed and filtered free of recognised option declarations. +If you're building complex subcommands with their own option-lists, you'll want `noMixedOrder` enabled. Seriously. + + + +noUndefined +----------- + +Throw a [`TypeError`](https://mdn.io/TypeError) if an unrecognised option is passed whilst still parsing options. + +Custom error messages may be specified to replace the default `Unknown option: "%s"`. If that isn't enough, you can also supply a callback to return something more specific to throw at the user. + + +terminator +---------- + +A string (conventionally a double-dash) signifying that option parsing is to stop and all remaining elements should be treated verbatim.