COMMANDS
This commit is contained in:
parent
b622adfcf8
commit
2f180c900e
@ -15,6 +15,9 @@ _dropshell_completions() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Get available commands from dropshell
|
||||
local commands=($(dropshell autocomplete_list_commands))
|
||||
|
||||
# Command-specific completions
|
||||
case "${prev}" in
|
||||
status|templates|autocomplete_list_servers|autocomplete_list_services|autocomplete_list_commands)
|
||||
@ -28,9 +31,8 @@ _dropshell_completions() {
|
||||
COMPREPLY=( $(compgen -W "${servers[*]}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
# Handle completion for service names and commands after run/install/backup/etc
|
||||
if [[ ${COMP_CWORD} -ge 2 ]]; then
|
||||
run|install|backup)
|
||||
# Handle completion for run/install/backup commands
|
||||
if [[ ${COMP_CWORD} -eq 2 ]]; then
|
||||
# Second argument is server name
|
||||
local servers=($(dropshell autocomplete_list_servers))
|
||||
@ -42,17 +44,30 @@ _dropshell_completions() {
|
||||
local services=($(dropshell autocomplete_list_services "$server_name"))
|
||||
COMPREPLY=( $(compgen -W "${services[*]}" -- ${cur}) )
|
||||
return 0
|
||||
elif [[ ${COMP_CWORD} -eq 4 ]]; then
|
||||
if [[ ${COMP_WORDS[1]} == "run" ]]; then
|
||||
# Fourth argument is command name - only relevant for run.
|
||||
local commands=($(dropshell autocomplete_list_commands))
|
||||
elif [[ ${COMP_CWORD} -eq 4 && "${COMP_WORDS[1]}" == "run" ]]; then
|
||||
# Fourth argument is command name - only for run command
|
||||
COMPREPLY=( $(compgen -W "${commands[*]}" -- ${cur}) )
|
||||
return 0
|
||||
else
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
# if ${prev} is not in ${commands}
|
||||
if [[ ! " ${commands[*]} " =~ " ${prev} " ]]; then
|
||||
COMPREPLY=()
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
# Handle completion for template commands
|
||||
if [[ ${COMP_CWORD} -eq 2 ]]; then
|
||||
# Second argument is server name
|
||||
local servers=($(dropshell autocomplete_list_servers))
|
||||
COMPREPLY=( $(compgen -W "${servers[*]}" -- ${cur}) )
|
||||
return 0
|
||||
elif [[ ${COMP_CWORD} -eq 3 ]]; then
|
||||
# Third argument is service name
|
||||
local server_name="${COMP_WORDS[2]}"
|
||||
local services=($(dropshell autocomplete_list_services "$server_name"))
|
||||
COMPREPLY=( $(compgen -W "${services[*]}" -- ${cur}) )
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
Loading…
x
Reference in New Issue
Block a user