-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug fix in enabler_complete function
- Loading branch information
taleksovska
committed
Mar 25, 2024
1 parent
10bb09f
commit 3fa43de
Showing
1 changed file
with
13 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,30 @@ | ||
_enabler_complete() { | ||
local cur_word prev_word commands | ||
local cur_word prev_word | ||
|
||
# Get the current and previous words | ||
cur_word="${COMP_WORDS[COMP_CWORD]}" | ||
prev_word="${COMP_WORDS[COMP_CWORD-1]}" | ||
local categories="apps kind preflight platform setup version" | ||
|
||
case "$prev_word" in | ||
"enabler") # noqa | ||
commands="$categories" | ||
COMPREPLY=( $(compgen -W "apps kind preflight platform setup version" -- "$cur_word") ) | ||
;; | ||
esac | ||
|
||
# Initialize the variable to store previous words | ||
prev_words="" | ||
local apps="namespace" | ||
local kind="create delete status start stop" | ||
local platform="init info keys release version" | ||
local setup="init metallb istio" | ||
|
||
# Loop through previous words and concatenate them | ||
for ((i=1; i<COMP_CWORD; i++)); | ||
do | ||
prev_words="${prev_words}${COMP_WORDS[i]} " | ||
done | ||
|
||
# Trim any trailing whitespace | ||
prev_words="${prev_words% }" | ||
|
||
case "$prev_words" in | ||
"enabler apps") | ||
commands="$commands $apps" | ||
"apps") | ||
COMPREPLY=( $(compgen -W "namespace" -- "$cur_word") ) | ||
;; | ||
"platform") | ||
COMPREPLY=( $(compgen -W "init info keys release version" -- "$cur_word") ) | ||
;; | ||
"enabler kind") | ||
commands="$commands $kind" | ||
"kind") | ||
COMPREPLY=( $(compgen -W "create delete status start stop" -- "$cur_word") ) | ||
;; | ||
"enabler platform") | ||
commands="$commands $platform" | ||
"setup") | ||
COMPREPLY=( $(compgen -W "init metallb istio" -- "$cur_word") ) | ||
;; | ||
"enabler setup") | ||
commands="$commands $setup" | ||
*) | ||
COMPREPLY=() | ||
;; | ||
esac | ||
|
||
echo "" | ||
echo "$commands" | ||
|
||
if [[ "$cur_word" == "$prev_word"* ]]; then | ||
COMPREPLY=( $(compgen -W "$commands" -- "$cur_word") ) | ||
fi | ||
} | ||
|
||
# Register _enabler_complete to provide completion for the enabler command | ||
complete -F _enabler_complete enabler |