diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2020-01-02 16:27:23 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2020-01-02 16:27:23 +0100 |
commit | 3f2c2cc1189e8bc68c5098865d7c7a437688bf64 (patch) | |
tree | d229554716a34488cfd916baceca8dd48a467406 /complete.c | |
parent | ecfe19dd1bb589b6a3e832e2b2be82828b7d0a51 (diff) | |
download | drminfo-3f2c2cc1189e8bc68c5098865d7c7a437688bf64.tar.gz |
output completion
Diffstat (limited to 'complete.c')
-rw-r--r-- | complete.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -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); } |