]> git.proxmox.com Git - mirror_frr.git/blobdiff - vtysh/vtysh.c
lib: add ability to dump cli mode graph
[mirror_frr.git] / vtysh / vtysh.c
index ec212233f66af48a2058455e301bd8ff5534bd61..50d6ee45899a732bae394e645475a97bc9158226 100644 (file)
@@ -43,6 +43,7 @@
 #include "ns.h"
 #include "vrf.h"
 #include "libfrr.h"
+#include "command_graph.h"
 
 DEFINE_MTYPE_STATIC(MVTYSH, VTYSH_CMD, "Vtysh cmd copy")
 
@@ -2957,10 +2958,26 @@ DEFUN(find,
        return CMD_SUCCESS;
 }
 
+DEFUN_HIDDEN(show_cli_graph_vtysh,
+            show_cli_graph_vtysh_cmd,
+            "show cli graph",
+            SHOW_STR
+            "CLI reflection\n"
+            "Dump current command space as DOT graph\n")
+{
+       struct cmd_node *cn = vector_slot(cmdvec, vty->node);
+       char *dot = cmd_graph_dump_dot(cn->cmdgraph);
+
+       vty_out(vty, "%s\n", dot);
+       XFREE(MTYPE_TMP, dot);
+       return CMD_SUCCESS;
+}
+
 static void vtysh_install_default(enum node_type node)
 {
        install_element(node, &config_list_cmd);
        install_element(node, &find_cmd);
+       install_element(node, &show_cli_graph_vtysh_cmd);
        install_element(node, &vtysh_output_file_cmd);
        install_element(node, &no_vtysh_output_file_cmd);
 }