From 90c8406c209a698ecc28c80ad7ebced13a84e3e8 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Thu, 26 Aug 2021 11:43:08 +0200 Subject: 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 --- lib/command_graph.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/command_graph.c') diff --git a/lib/command_graph.c b/lib/command_graph.c index c6c3840455..15c8302e63 100644 --- a/lib/command_graph.c +++ b/lib/command_graph.c @@ -388,6 +388,7 @@ static void cmd_node_names(struct graph_node *gn, struct graph_node *join, case START_TKN: case JOIN_TKN: + case NEG_ONLY_TKN: /* " WORD" -> word is not "bar" or "foo" */ prevname = NULL; break; @@ -511,6 +512,9 @@ void cmd_graph_node_print_cb(struct graph_node *gn, struct buffer *buf) case JOIN_TKN: color = "#ddaaff"; break; + case NEG_ONLY_TKN: + color = "#ffddaa"; + break; case WORD_TKN: color = "#ffffff"; break; -- cgit v1.2.3