]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
cli: Allow command completion to be disabled
authorSimon Glass <sjg@chromium.org>
Mon, 2 Oct 2023 01:13:16 +0000 (19:13 -0600)
committerTom Rini <trini@konsulko.com>
Wed, 11 Oct 2023 19:43:54 +0000 (15:43 -0400)
When inputting text outside the command line we don't want to use tab
for command completion. Add an option to control this.

Signed-off-by: Simon Glass <sjg@chromium.org>
common/cli_readline.c
include/cli.h

index fa8f525d3a41769fc60f42a2e2ef982d0d177525..23913a857a995f54bb68beeda00fc9900bc60089 100644 (file)
@@ -389,7 +389,7 @@ int cread_line_process_ch(struct cli_line_state *cls, char ichar)
                }
                break;
        case '\t':
-               if (IS_ENABLED(CONFIG_AUTO_COMPLETE)) {
+               if (IS_ENABLED(CONFIG_AUTO_COMPLETE) && cls->cmd_complete) {
                        int num2, col;
 
                        /* do not autocomplete when in the middle */
@@ -440,6 +440,7 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len,
        cls->prompt = prompt;
        cls->buf = buf;
        cls->history = true;
+       cls->cmd_complete = true;
 
        if (init_len)
                cread_add_str(buf, init_len, 1, &cls->num, &cls->eol_num, buf,
index 252bdb70ab0da0bfb5326cf5a135b1f7db3d7613..ad3cb4499fe12e91544855478ea6c18b68c9ec67 100644 (file)
@@ -32,6 +32,7 @@ struct cli_ch_state {
  * @eol_num: Number of characters in the buffer
  * @insert: true if in 'insert' mode
  * @history: true if history should be accessible
+ * @cmd_complete: true if tab completion should be enabled
  * @buf: Buffer containing line
  * @prompt: Prompt for the line
  */
@@ -41,6 +42,7 @@ struct cli_line_state {
        uint len;
        bool insert;
        bool history;
+       bool cmd_complete;
        char *buf;
        const char *prompt;
 };