]> git.puffer.fish Git - matthieu/frr.git/commitdiff
doc, vtysh: Add a `show history` command
authorDonald Sharp <sharpd@nvidia.com>
Thu, 3 Dec 2020 17:36:29 +0000 (12:36 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Thu, 3 Dec 2020 17:36:29 +0000 (12:36 -0500)
Dump the cli history to the user in vtysh when a `show history`
command is entered.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
doc/user/basic.rst
vtysh/vtysh.c

index e941053f8cb352b3302e15dba2b0bce56fdb9a86..1ca3ca3cf2ee5d24f2816c13d4a0bfbccc91e105 100644 (file)
@@ -549,6 +549,11 @@ Terminal Mode Commands
    When executing this command from ``vtysh``, each of the daemons' memory
    usage is printed sequentially.
 
+.. index:: show history
+.. clicmd:: show history
+
+   Dump the vtysh cli history.
+
 .. index:: logmsg LEVEL MESSAGE
 .. clicmd:: logmsg LEVEL MESSAGE
 
index ef0dfccba91f50fb44931a52edf3041d4ee09f8a..c78132508fddfee71dba1864117a6ff7ef71ec6a 100644 (file)
@@ -2676,6 +2676,22 @@ DEFUNSH(VTYSH_ALL, debug_nb,
        return CMD_SUCCESS;
 }
 
+DEFUN (vtysh_show_history,
+       vtysh_show_history_cmd,
+       "show history",
+       SHOW_STR
+       "The list of commands stored in history\n")
+{
+       HIST_ENTRY **hlist = history_list();
+       int i = 0;
+
+       while (hlist[i]) {
+               vty_out(vty, "%s\n", hlist[i]->line);
+               i++;
+       }
+       return CMD_SUCCESS;
+}
+
 /* Memory */
 DEFUN (vtysh_show_memory,
        vtysh_show_memory_cmd,
@@ -4270,6 +4286,7 @@ void vtysh_init_vty(void)
        install_element(CONFIG_NODE, &debug_nb_cmd);
 
        /* misc lib show commands */
+       install_element(VIEW_NODE, &vtysh_show_history_cmd);
        install_element(VIEW_NODE, &vtysh_show_memory_cmd);
        install_element(VIEW_NODE, &vtysh_show_modules_cmd);
        install_element(VIEW_NODE, &vtysh_show_work_queues_cmd);