From 5d20463d9fe2b98db639f6c9c01480092390035e Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 2 Jan 2020 16:53:13 +0100 Subject: format completion --- complete.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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); } -- cgit