client: Entity argument completion

This commit is contained in:
Tim Kourt 2017-04-20 16:23:10 -07:00 committed by Denis Kenzior
parent c85ea2f924
commit 02b52adf61
2 changed files with 27 additions and 0 deletions

View File

@ -253,6 +253,31 @@ done:
return matches;
}
char *command_entity_arg_completion(const char *text, int state,
const struct command *command_list)
{
static size_t index;
static size_t len;
const char *cmd;
if (!state) {
index = 0;
len = strlen(text);
}
while ((cmd = command_list[index].cmd)) {
if (!command_list[index++].entity)
continue;
if (strncmp(cmd, text, len))
continue;
return l_strdup(cmd);
}
return NULL;
}
static void execute_cmd(const char *family, const char *entity,
const struct command *cmd, char *args)
{

View File

@ -41,6 +41,8 @@ struct command_family {
};
char **command_completion(const char *text, int start, int end);
char *command_entity_arg_completion(const char *text, int state,
const struct command *command_list);
void command_process_prompt(char *prompt);