summaryrefslogtreecommitdiff
path: root/doc/developer/cli.rst
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2021-08-26 11:43:08 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2021-08-26 21:03:44 +0200
commit90c8406c209a698ecc28c80ad7ebced13a84e3e8 (patch)
tree74bedac5f4d8c3bc5b1bdfb42e6eefaa001d714c /doc/developer/cli.rst
parent3e324ff41921c719de3aabc4136546828416532f (diff)
lib: add `![...]` syntax for easy "no" forms
This allows defining a CLI command like this: `[no] some setting ![VALUE]` with VALUE being optional for the "no" form, but required for the positive form. It's just a `[...]` where the empty branch can only be taken for commands starting with `no`. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'doc/developer/cli.rst')
-rw-r--r--doc/developer/cli.rst5
1 files changed, 5 insertions, 0 deletions
diff --git a/doc/developer/cli.rst b/doc/developer/cli.rst
index edabe61d92..a24a4ecb7e 100644
--- a/doc/developer/cli.rst
+++ b/doc/developer/cli.rst
@@ -139,6 +139,7 @@ by the parser.
selector: "<" `selector_seq_seq` ">" `varname_token`
: "{" `selector_seq_seq` "}" `varname_token`
: "[" `selector_seq_seq` "]" `varname_token`
+ : "![" `selector_seq_seq` "]" `varname_token`
selector_seq_seq: `selector_seq_seq` "|" `selector_token_seq`
: `selector_token_seq`
selector_token_seq: `selector_token_seq` `selector_token`
@@ -218,6 +219,10 @@ one-or-more selection and repetition.
provide mutual exclusion. User input matches at most one option.
- ``[square brackets]`` -- Contains sequences of tokens that can be omitted.
``[<a|b>]`` can be shortened to ``[a|b]``.
+- ``![exclamation square brackets]`` -- same as ``[square brackets]``, but
+ only allow skipping the contents if the command input starts with ``no``.
+ (For cases where the positive command needs a parameter, but the parameter
+ is optional for the negative case.)
- ``{curly|braces}`` -- similar to angle brackets, but instead of mutual
exclusion, curly braces indicate that one or more of the pipe-separated
sequences may be provided in any order.