aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2020-01-02 16:53:13 +0100
committerGerd Hoffmann <kraxel@redhat.com>2020-01-02 16:53:13 +0100
commit5d20463d9fe2b98db639f6c9c01480092390035e (patch)
tree10a9eed0161438ce9b0d7c5317b95f22d105614a
parente47b389991c6adbed6e1831a92b2e48d9513b89d (diff)
downloaddrminfo-5d20463d9fe2b98db639f6c9c01480092390035e.tar.gz
format completion
-rw-r--r--complete.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/complete.c b/complete.c
index 87b3332..06efc0f 100644
--- a/complete.c
+++ b/complete.c
@@ -29,12 +29,19 @@
" COMPREPLY=( $(compgen -W \"$words\" -- \"$cur\") )\n" \
" ;;\n"
+#define CASE_FORMAT \
+ " --format)\n" \
+ " words=$(drminfo --test-formats)\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;
+ bool have_format = false;
char opt_all[1024];
char opt_arg[1024];
int pos_all = 0;
@@ -55,6 +62,8 @@ void complete_bash(const char *command, struct option *opts)
have_fbdev = true;
} else if (strcmp(opts[i].name, "output") == 0) {
have_output = true;
+ } else if (strcmp(opts[i].name, "format") == 0) {
+ have_format = true;
} else if (opts[i].has_arg) {
/* options without argument completion */
@@ -79,7 +88,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%s"
" %s)\n"
" COMPREPLY=()\n"
" ;;\n"
@@ -96,6 +105,7 @@ void complete_bash(const char *command, struct option *opts)
have_card ? CASE_CARD : "",
have_fbdev ? CASE_FBDEV : "",
have_output ? CASE_OUTPUT : "",
+ have_format ? CASE_FORMAT : "",
opt_arg, opt_all, command, command);
}