Skip to content

Commit

Permalink
xe autocompletion: Only show required/optional prefixes when paramete…
Browse files Browse the repository at this point in the history
…r name is

empty

Otherwise, these prefixes break autocompletion of common prefixes, like in:
```
$ xe pool-param-get <TAB>
OPTIONAL: database:    REQUIRED: param-name=
OPTIONAL: param-key=   REQUIRED: uuid=
$ xe pool-param-get p<TAB> <- gets autocompleted before showing further
suggestions
$ xe pool-param-get param-
param-key=   param-name=
```

Without this fix, instead worked like this:
```
$ xe pool-param-get <TAB>
OPTIONAL: database:    REQUIRED: param-name=
OPTIONAL: param-key=   REQUIRED: uuid=
$ xe pool-param-get p<TAB> <-- no prefix autocompletion
OPTIONAL: param-key=   REQUIRED: param-name=
```

This is a temporary workaround, since upgrading bash would allow us to show
prefixes as section headers without polluting suggested words themselves.

Signed-off-by: Andrii Sultanov <[email protected]>
  • Loading branch information
last-genius committed Sep 2, 2024
1 parent bb0411c commit b60a081
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ocaml/xe-cli/bash-completion
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,9 @@ _xe()
__xe_debug "triggering autocompletion for parameter names, param is '$param'"

IFS=$'\n,'
REQD_OPTIONAL_PARAMS=1
if [ ! "$param" ]; then
REQD_OPTIONAL_PARAMS=1
fi
get_params_for_command "${OLDSTYLE_WORDS[1]}"

# Don't suggest already provided parameters
Expand Down

0 comments on commit b60a081

Please sign in to comment.