diff options
| author | David Lamparter <equinox@opensourcerouting.org> | 2016-11-19 11:57:08 +0100 |
|---|---|---|
| committer | Quentin Young <qlyoung@users.noreply.github.com> | 2017-05-15 10:27:43 -0400 |
| commit | 70d44c5cd4f28f9d08a24f519d859885d92e2a13 (patch) | |
| tree | c67e6c907a31487ca96b27e53a1f571c26f31bf9 /lib/routemap.c | |
| parent | c09c46ae3c2702b3553e558f723e6de4fea3e05d (diff) | |
lib: cli: autocomplete variables
Shows known values in the appropriate naming domain when the user hits
<?> or <Tab>. This patch only works in the telnet CLI, the next patch
adds vtysh support.
Included completions:
- interface names
- route-map names
- prefix-list names
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/routemap.c')
| -rw-r--r-- | lib/routemap.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/routemap.c b/lib/routemap.c index cd34ffaae5..482155987d 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -2001,7 +2001,7 @@ DEFUN (match_interface, DEFUN (no_match_interface, no_match_interface_cmd, - "no match interface [INTERFACE]", + "no match interface [WORD]", NO_STR MATCH_STR "Match first hop interface of route\n" @@ -2958,6 +2958,30 @@ route_map_finish (void) route_map_master_hash = NULL; } +static void rmap_autocomplete(vector comps, struct cmd_token *token) +{ + struct route_map *map; + + for (map = route_map_master.head; map; map = map->next) + vector_set (comps, XSTRDUP (MTYPE_COMPLETION, map->name)); +} + +static const struct cmd_variable_handler rmap_var_handlers[] = { + { + /* "route-map WORD" */ + .varname = "route_map", + .completions = rmap_autocomplete + }, { + .tokenname = "ROUTEMAP_NAME", + .completions = rmap_autocomplete + }, { + .tokenname = "RMAP_NAME", + .completions = rmap_autocomplete + }, { + .completions = NULL + } +}; + /* Initialization of route map vector. */ void route_map_init (void) @@ -2973,6 +2997,8 @@ route_map_init (void) route_map_dep_hash[i] = hash_create(route_map_dep_hash_make_key, route_map_dep_hash_cmp); + cmd_variable_handler_register(rmap_var_handlers); + /* Install route map top node. */ install_node (&rmap_node, route_map_config_write); |
