summaryrefslogtreecommitdiff
path: root/lib/vty.c
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2017-07-12 14:40:18 -0400
committerQuentin Young <qlyoung@cumulusnetworks.com>2017-07-13 10:59:13 -0400
commit1a0f614dd29f8666647e005c63ae00b3638234d4 (patch)
tree27ec799a1ff07ef27855848fad388a2e7613d6e6 /lib/vty.c
parent4c25598b4e5e33915afdf829fb38b8565dd1f2f9 (diff)
lib, vtysh: pretty-print variable autocompletions
Pretty-prints variable autocompletions by breaking them up into multiple lines, indenting them consistently and respecting the column width of the terminal. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/vty.c')
-rw-r--r--lib/vty.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/lib/vty.c b/lib/vty.c
index e6497b3100..dd8dac74b6 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -1134,17 +1134,13 @@ vty_describe_command (struct vty *vty)
vector varcomps = vector_init (VECTOR_MIN_SIZE);
cmd_variable_complete (token, ref, varcomps);
- if (vector_active(varcomps) > 0)
+ if (vector_active (varcomps) > 0)
{
- vty_out(vty, " ");
- for (size_t j = 0; j < vector_active (varcomps); j++)
- {
- char *item = vector_slot (varcomps, j);
- vty_out(vty, " %s", item);
- XFREE(MTYPE_COMPLETION, item);
- }
- vty_out (vty, VTYNL);
+ char *ac = cmd_variable_comp2str(varcomps, vty->width, VTYNL);
+ vty_outln(vty, "%s", ac);
+ XFREE(MTYPE_TMP, ac);
}
+
vector_free(varcomps);
}
#if 0