Fix auto completion

This commit is contained in:
Your Name 2025-04-21 20:42:19 +12:00
parent b53e0f6654
commit 03b02b9094

View File

@ -5,6 +5,7 @@ _dropshell_completions() {
COMPREPLY=() COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
root="${COMP_WORDS[1]}"
# List of main commands # List of main commands
opts="help version servers templates autocomplete_list_servers autocomplete_list_services autocomplete_list_commands install backup" opts="help version servers templates autocomplete_list_servers autocomplete_list_services autocomplete_list_commands install backup"
@ -20,8 +21,8 @@ _dropshell_completions() {
fi fi
# Command-specific completions # Command-specific completions
case "${prev}" in case "${root}" in
status|templates|autocomplete_list_servers|autocomplete_list_services|autocomplete_list_commands) templates|autocomplete_list_servers|autocomplete_list_services|autocomplete_list_commands)
# No additional completions for these commands # No additional completions for these commands
COMPREPLY=() COMPREPLY=()
return 0 return 0
@ -49,7 +50,7 @@ _dropshell_completions() {
;; ;;
*) *)
# if ${prev} is not in ${commands} # if ${prev} is not in ${commands}
if [[ ! " ${commands[*]} " =~ " ${prev} " ]]; then if [[ ! " ${commands[*]} " =~ " ${root} " ]]; then
COMPREPLY=() COMPREPLY=()
return 0 return 0
fi fi