2023-11-23 02:34:02 +03:00
|
|
|
# compute bash completion script
|
|
|
|
|
|
|
|
_compute_root_cmd="
|
|
|
|
--version
|
|
|
|
--verbose
|
|
|
|
--connect
|
|
|
|
--log-level
|
|
|
|
init
|
|
|
|
exec
|
|
|
|
ls
|
|
|
|
start
|
|
|
|
shutdown
|
|
|
|
reboot
|
|
|
|
reset
|
|
|
|
powrst
|
|
|
|
pause
|
|
|
|
resume
|
|
|
|
status
|
|
|
|
setvcpus
|
|
|
|
setmem
|
2023-12-01 01:39:26 +03:00
|
|
|
setpass"
|
2023-11-23 02:34:02 +03:00
|
|
|
_compute_init_opts=""
|
2023-12-01 01:39:26 +03:00
|
|
|
_compute_exec_opts="--timeout --executable --env --no-join-args"
|
2023-11-23 02:34:02 +03:00
|
|
|
_compute_ls_opts=""
|
|
|
|
_compute_start_opts=""
|
2023-12-01 01:39:26 +03:00
|
|
|
_compute_shutdown_opts="--soft --normal --hard --unsafe"
|
2023-11-23 02:34:02 +03:00
|
|
|
_compute_reboot_opts=""
|
|
|
|
_compute_reset_opts=""
|
|
|
|
_compute_powrst_opts=""
|
|
|
|
_compute_pause_opts=""
|
|
|
|
_compute_resume_opts=""
|
|
|
|
_compute_status_opts=""
|
|
|
|
_compute_setvcpus_opts=""
|
|
|
|
_compute_setmem_opts=""
|
2023-12-01 01:39:26 +03:00
|
|
|
_compute_setpass_opts="--encrypted"
|
2023-11-23 02:34:02 +03:00
|
|
|
|
|
|
|
_compute_complete_instances()
|
|
|
|
{
|
2023-12-01 01:39:26 +03:00
|
|
|
local base_name
|
2023-11-23 02:34:02 +03:00
|
|
|
for file in /etc/libvirt/qemu/*.xml; do
|
2023-12-01 01:39:26 +03:00
|
|
|
base_name="${file##*/}"
|
|
|
|
printf '%s ' "${base_name//\.xml}"
|
2023-11-23 02:34:02 +03:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
_compute_compreply()
|
|
|
|
{
|
|
|
|
if [[ "$current" = [a-z]* ]]; then
|
|
|
|
_compute_compwords="$(_compute_complete_instances)"
|
|
|
|
else
|
|
|
|
_compute_compwords="$*"
|
|
|
|
fi
|
|
|
|
COMPREPLY=($(compgen -W "$_compute_compwords" -- "$current"))
|
|
|
|
}
|
|
|
|
|
|
|
|
_compute_complete()
|
|
|
|
{
|
|
|
|
local current previous nshift
|
|
|
|
current="${COMP_WORDS[COMP_CWORD]}"
|
|
|
|
case "$COMP_CWORD" in
|
|
|
|
1) COMPREPLY=($(compgen -W "$_compute_root_cmd" -- "$current"))
|
|
|
|
;;
|
|
|
|
2|3|4|5)
|
|
|
|
nshift=$((COMP_CWORD-1))
|
|
|
|
previous="${COMP_WORDS[COMP_CWORD-nshift]}"
|
|
|
|
case "$previous" in
|
|
|
|
init) COMPREPLY=($(compgen -f -- "$current"));;
|
|
|
|
exec) _compute_compreply "$_compute_exec_opts";;
|
|
|
|
ls) COMPREPLY=($(compgen -W "$_compute_ls_opts" -- "$current"));;
|
|
|
|
start) _compute_compreply "$_compute_start_opts";;
|
|
|
|
shutdown) _compute_compreply "$_compute_shutdown_opts";;
|
|
|
|
reboot) _compute_compreply "$_compute_reboot_opts";;
|
|
|
|
reset) _compute_compreply "$_compute_reset_opts";;
|
|
|
|
powrst) _compute_compreply "$_compute_powrst_opts";;
|
|
|
|
pause) _compute_compreply "$_compute_pause_opts";;
|
|
|
|
resume) _compute_compreply "$_compute_resume_opts";;
|
|
|
|
status) _compute_compreply "$_compute_status_opts";;
|
|
|
|
setvcpus) _compute_compreply "$_compute_setvcpus_opts";;
|
|
|
|
setmem) _compute_compreply "$_compute_setmem_opts";;
|
2023-12-01 01:39:26 +03:00
|
|
|
setpass) _compute_compreply "$_compute_setpass_opts";;
|
2023-11-23 02:34:02 +03:00
|
|
|
*) COMPREPLY=()
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
*) COMPREPLY=($(compgen -W "$_compute_compwords" -- "$current"))
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
complete -F _compute_complete compute
|
|
|
|
|
|
|
|
# vim: ft=bash
|