From 0e06eb8b2ea1eff8c67752533d66e96bb9bebfdb Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Mon, 18 Oct 2021 11:51:09 +0200 Subject: vtysh: defer CLI tree building We don't need the CLI tree until we actually enter the node. Signed-off-by: David Lamparter --- lib/command.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/command.h') diff --git a/lib/command.h b/lib/command.h index e2eec1aac6..e2086701ad 100644 --- a/lib/command.h +++ b/lib/command.h @@ -210,6 +210,9 @@ struct cmd_node { /* Hashed index of command node list, for de-dupping primarily */ struct hash *cmd_hash; + + /* set as soon as any command is in cmdgraph */ + bool graph_built; }; /* Return value of the commands. */ @@ -526,6 +529,12 @@ extern void _install_element(enum node_type, const struct cmd_element *); * deprecated/hidden) are not reversed. */ extern void uninstall_element(enum node_type, const struct cmd_element *); +/* construct CLI tree only when entering nodes */ +extern void cmd_defer_tree(bool val); + +/* finish CLI tree for node when above is true (noop otherwise) */ +extern void cmd_finalize_node(struct cmd_node *node); + /* Concatenates argv[shift] through argv[argc-1] into a single NUL-terminated string with a space between each element (allocated using XMALLOC(MTYPE_TMP)). Returns NULL if shift >= argc. */ -- cgit v1.2.3