aboutsummaryrefslogtreecommitdiffstats
path: root/complete.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2020-01-02 16:27:23 +0100
committerGerd Hoffmann <kraxel@redhat.com>2020-01-02 16:27:23 +0100
commit3f2c2cc1189e8bc68c5098865d7c7a437688bf64 (patch)
treed229554716a34488cfd916baceca8dd48a467406 /complete.c
parentecfe19dd1bb589b6a3e832e2b2be82828b7d0a51 (diff)
downloaddrminfo-3f2c2cc1189e8bc68c5098865d7c7a437688bf64.tar.gz
output completion
Diffstat (limited to 'complete.c')
-rw-r--r--complete.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/complete.c b/complete.c
index 2e9d4a1..87b3332 100644
--- a/complete.c
+++ b/complete.c
@@ -23,11 +23,18 @@
" COMPREPLY=( $(compgen -W \"$words\" -- \"$cur\") )\n" \
" ;;\n"
+#define CASE_OUTPUT \
+ " --output)\n" \
+ " words=$(drminfo --complete-output)\n" \
+ " COMPREPLY=( $(compgen -W \"$words\" -- \"$cur\") )\n" \
+ " ;;\n"
+
void complete_bash(const char *command, struct option *opts)
{
bool have_image = false;
bool have_card = false;
bool have_fbdev = false;
+ bool have_output = false;
char opt_all[1024];
char opt_arg[1024];
int pos_all = 0;
@@ -46,6 +53,8 @@ void complete_bash(const char *command, struct option *opts)
have_card = true;
} else if (strcmp(opts[i].name, "fbdev") == 0) {
have_fbdev = true;
+ } else if (strcmp(opts[i].name, "output") == 0) {
+ have_output = true;
} else if (opts[i].has_arg) {
/* options without argument completion */
@@ -70,7 +79,7 @@ void complete_bash(const char *command, struct option *opts)
" cur=\"${COMP_WORDS[COMP_CWORD]}\"\n"
" prev=\"${COMP_WORDS[COMP_CWORD-1]}\"\n"
" case \"$prev\" in\n"
- "%s%s%s"
+ "%s%s%s%s"
" %s)\n"
" COMPREPLY=()\n"
" ;;\n"
@@ -83,9 +92,10 @@ void complete_bash(const char *command, struct option *opts)
"complete -F _%s_complete %s\n"
"\n",
command,
- have_image ? CASE_IMAGE : "",
- have_card ? CASE_CARD : "",
- have_fbdev ? CASE_FBDEV : "",
+ have_image ? CASE_IMAGE : "",
+ have_card ? CASE_CARD : "",
+ have_fbdev ? CASE_FBDEV : "",
+ have_output ? CASE_OUTPUT : "",
opt_arg, opt_all, command, command);
}