From 21687e9a81d911d04effe34668a7c298dd72c697 Mon Sep 17 00:00:00 2001 From: Tim Kourt Date: Fri, 21 Apr 2017 11:14:54 -0700 Subject: [PATCH] client: Argument completion for known-networks --- client/known-networks.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/client/known-networks.c b/client/known-networks.c index 34defe9a..9078b841 100644 --- a/client/known-networks.c +++ b/client/known-networks.c @@ -48,10 +48,35 @@ static const struct command known_networks_commands[] = { { } }; +static char *family_arg_completion(const char *text, int state) +{ + static size_t index; + static size_t len; + const char *cmd; + + if (!state) { + index = 0; + len = strlen(text); + } + + while ((cmd = known_networks_commands[index].cmd)) { + if (known_networks_commands[index++].entity) + continue; + + if (strncmp(cmd, text, len)) + continue; + + return l_strdup(cmd); + } + + return NULL; +} + static struct command_family known_networks_command_family = { .caption = "Known Networks", .name = "known-networks", .command_list = known_networks_commands, + .family_arg_completion = family_arg_completion, }; static int known_networks_command_family_init(void)