degesch: fix option completion
This commit is contained in:
parent
e3f1bcecae
commit
715def6555
19
degesch.c
19
degesch.c
|
@ -5212,12 +5212,21 @@ complete_option (struct app_context *ctx, struct completion *data,
|
||||||
struct str_vector options;
|
struct str_vector options;
|
||||||
str_vector_init (&options);
|
str_vector_init (&options);
|
||||||
|
|
||||||
// Wildcard expansion is an interesting side-effect
|
config_dump (ctx->config.root, &options);
|
||||||
char *x = xstrdup_printf ("%s*", word);
|
str_vector_sort (&options);
|
||||||
dump_matching_options (ctx, x, &options);
|
|
||||||
free (x);
|
|
||||||
|
|
||||||
str_vector_add_vector (output, options.vector);
|
// Wildcard expansion is an interesting side-effect
|
||||||
|
char *mask = xstrdup_printf ("%s*", word);
|
||||||
|
for (size_t i = 0; i < options.len; i++)
|
||||||
|
{
|
||||||
|
const char *line = options.vector[i];
|
||||||
|
char *key = xstrndup (line, strcspn (line, " "));
|
||||||
|
if (!fnmatch (mask, key, 0))
|
||||||
|
str_vector_add_owned (output, key);
|
||||||
|
else
|
||||||
|
free (key);
|
||||||
|
}
|
||||||
|
free (mask);
|
||||||
str_vector_free (&options);
|
str_vector_free (&options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue