Merge pull request #7663 from donaldsharp/vtysh_history_display

doc, vtysh: Add a `show history` command
This commit is contained in:
Donatas Abraitis 2020-12-04 10:25:18 +02:00 committed by GitHub
commit 057edd2e84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -549,6 +549,11 @@ Terminal Mode Commands
When executing this command from ``vtysh``, each of the daemons' memory When executing this command from ``vtysh``, each of the daemons' memory
usage is printed sequentially. usage is printed sequentially.
.. index:: show history
.. clicmd:: show history
Dump the vtysh cli history.
.. index:: logmsg LEVEL MESSAGE .. index:: logmsg LEVEL MESSAGE
.. clicmd:: logmsg LEVEL MESSAGE .. clicmd:: logmsg LEVEL MESSAGE

View File

@ -2676,6 +2676,22 @@ DEFUNSH(VTYSH_ALL, debug_nb,
return CMD_SUCCESS; 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 */ /* Memory */
DEFUN (vtysh_show_memory, DEFUN (vtysh_show_memory,
vtysh_show_memory_cmd, vtysh_show_memory_cmd,
@ -4270,6 +4286,7 @@ void vtysh_init_vty(void)
install_element(CONFIG_NODE, &debug_nb_cmd); install_element(CONFIG_NODE, &debug_nb_cmd);
/* misc lib show commands */ /* 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_memory_cmd);
install_element(VIEW_NODE, &vtysh_show_modules_cmd); install_element(VIEW_NODE, &vtysh_show_modules_cmd);
install_element(VIEW_NODE, &vtysh_show_work_queues_cmd); install_element(VIEW_NODE, &vtysh_show_work_queues_cmd);