mirror of
https://github.com/gryf/vboxmanage-bash-completion.git
synced 2025-12-19 12:28:19 +01:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 62d9078b23 | |||
| 3f42dd2dc1 | |||
| 6ee3136033 | |||
| cf367c093d | |||
| 7174fe03db | |||
| f2d71065cb | |||
| 82e2fade6b |
@@ -6,7 +6,7 @@ script. However, in some point of time I've decided to rewrite it almost from
|
||||
scratch.
|
||||
|
||||
Current version of script was written and tested against VBoxManage in version
|
||||
6.1.10, and should contain all commands and their options.
|
||||
6.1.36, and should contain all commands and their options.
|
||||
|
||||
Unlike other attempts, I've tried to make the script context aware. See the
|
||||
simple session with the VBoxManage command below, to have an idea how it works:
|
||||
|
||||
68
VBoxManage
68
VBoxManage
@@ -4,7 +4,7 @@
|
||||
# URL: https://bitbucket.org/gryf/vboxmanage-bash-completion
|
||||
# URL: https://github.com/gryf/vboxmanage-bash-completion
|
||||
# License: 3-clause BSD-style license (see LICENSE file)
|
||||
# Version: 6.1.10
|
||||
# Version: 6.1.36
|
||||
|
||||
|
||||
_VBoxManage() {
|
||||
@@ -486,16 +486,18 @@ _VBoxManage() {
|
||||
|
||||
# all possible commands for the VBoxManage
|
||||
opts=$(VBoxManage -q help | \
|
||||
egrep -o "^\s\s[a-z]+ " | \
|
||||
grep -E -o "^\s\s[a-z]+ " | \
|
||||
grep -v VBoxManage | \
|
||||
awk '{print $1}'| \
|
||||
sort | \
|
||||
uniq)
|
||||
|
||||
# Add some commands manually, since they are listed differently in
|
||||
# vboxmanage help.
|
||||
opts="${opts} mediumio debugvm unattended extpack clonevm snapshot
|
||||
dhcpserver cloudprofile cloud"
|
||||
# Add commands which are defined as ` VBoxManage commandname ` in a help.
|
||||
opts="${opts} $(VBoxManage -q help | \
|
||||
grep -E -o '^\s\s[a-zA-Z]+\s[a-z]+' | \
|
||||
awk '{print $2}'| \
|
||||
sort | \
|
||||
uniq)"
|
||||
|
||||
if [[ ${cur} == "-q" || ${COMP_CWORD} -eq 1 ]] ; then
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
@@ -691,14 +693,19 @@ _VBoxManage() {
|
||||
;;
|
||||
|
||||
cloud)
|
||||
if [[ " ${COMP_WORDS[@]} " != *" --provider"* ||
|
||||
if [ "${prev}" == "cloud" ]; then
|
||||
items=(--provider --profile network)
|
||||
elif [[ " ${COMP_WORDS[@]} " == *" network"* ]]; then
|
||||
items=(update delete info)
|
||||
elif [[ " ${COMP_WORDS[@]} " != *" --provider"* ||
|
||||
" ${COMP_WORDS[@]} " != *" --profile"* ]]; then
|
||||
items=(--provider --profile)
|
||||
else
|
||||
[[ " ${COMP_WORDS[@]} " != *" list"* &&
|
||||
" ${COMP_WORDS[@]} " != *" instance"* &&
|
||||
" ${COMP_WORDS[@]} " != *" network"* &&
|
||||
" ${COMP_WORDS[@]} " != *" image"* ]] &&
|
||||
items=(list instance image)
|
||||
items=(list instance image network)
|
||||
fi
|
||||
_get_excluded_items "${items[@]}"
|
||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||
@@ -722,7 +729,11 @@ _VBoxManage() {
|
||||
COMPREPLY=( $(compgen -W "create info delete import
|
||||
export" -- ${cur}) )
|
||||
;;
|
||||
|
||||
network) # TODO: differentiate between setup/create and update/delete/info
|
||||
if [[ " ${COMP_WORDS[@]} " == *" --provider"* ]]; then
|
||||
COMPREPLY=( $(compgen -W "setup create" -- ${cur}) )
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
if [[ " ${COMP_WORDS[@]} " == *" list images"* ]]; then
|
||||
|
||||
@@ -732,8 +743,9 @@ _VBoxManage() {
|
||||
fi
|
||||
|
||||
if [[ " ${COMP_WORDS[@]} " == *" instance create"* ]]; then
|
||||
items=(--domain-name --display-name --shape --subnet --publicip
|
||||
--boot-disk-size --privateip --public-ssh-key --launch-mode)
|
||||
items=( --domain-name --display-name --shape --subnet
|
||||
--publicip --boot-disk-size --privateip --public-ssh-key
|
||||
--launch-mode --cloud-init-script-path )
|
||||
[[ " ${COMP_WORDS[@]} " != *" --image-id"* &&
|
||||
" ${COMP_WORDS[@]} " != *" --boot-volume-id"* ]] &&
|
||||
items+=(--image-id --boot-volume-id)
|
||||
@@ -776,6 +788,34 @@ _VBoxManage() {
|
||||
COMPREPLY=( $(compgen -W "--id --display-name --bucket-name
|
||||
--object-name" -- ${cur}) )
|
||||
fi
|
||||
if [[ " ${COMP_WORDS[@]} " == *" network setup"* ]]; then
|
||||
items=( --local-gateway-iso --gateway-os-name
|
||||
--gateway-os-version --gateway-shape --tunnel-network-name
|
||||
--tunnel-network-range --guest-additions-iso --proxy
|
||||
--compartment-id )
|
||||
_get_excluded_items "${items[@]}"
|
||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||
fi
|
||||
if [[ " ${COMP_WORDS[@]} " == *" network create"* ]]; then
|
||||
items=( --name --network-id )
|
||||
[[ " ${COMP_WORDS[@]} " != *" --enable"* &&
|
||||
" ${COMP_WORDS[@]} " != *" --disable"* ]] &&
|
||||
items+=(--enable --disable)
|
||||
_get_excluded_items "${items[@]}"
|
||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||
fi
|
||||
if [[ " ${COMP_WORDS[@]} " == *" network update"* ]]; then
|
||||
items=( --name --network-id )
|
||||
[[ " ${COMP_WORDS[@]} " != *" --enable"* &&
|
||||
" ${COMP_WORDS[@]} " != *" --disable"* ]] &&
|
||||
items+=(--enable --disable)
|
||||
_get_excluded_items "${items[@]}"
|
||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||
fi
|
||||
if [[ " ${COMP_WORDS[@]} " == *" network info"* ||
|
||||
" ${COMP_WORDS[@]} " == *" network delete"* ]]; then
|
||||
COMPREPLY=( $(compgen -W "--name" -- ${cur}) )
|
||||
fi
|
||||
;;
|
||||
|
||||
controlvm)
|
||||
@@ -1230,7 +1270,7 @@ _VBoxManage() {
|
||||
;;
|
||||
|
||||
"export")
|
||||
items=( --manifest --iso --options --vsys --cloud )
|
||||
items=( --manifest --options --vsys --cloud --cloudinitscriptpath )
|
||||
if [[ ${prev} == ${cmd} ]]; then
|
||||
_vms_comp vms
|
||||
elif [[ ${prev} == "--eulafile" ]]; then
|
||||
@@ -1256,7 +1296,7 @@ _VBoxManage() {
|
||||
items+=(--vmname --cloudprofile --cloudshape --clouddomain
|
||||
--clouddisksize --cloudbucket --cloudocivcn --cloudocisubnet
|
||||
--cloudkeepobject --cloudlaunchinstance --cloudpublicip
|
||||
--cloudprivateip --cloudlaunchmode)
|
||||
--cloudprivateip --cloudlaunchmode --cloudinitscriptpath )
|
||||
_get_excluded_items "${items[@]}"
|
||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||
|
||||
@@ -2304,7 +2344,7 @@ _VBoxManage() {
|
||||
case "${subcommand}" in
|
||||
add)
|
||||
items=(--name --hostpath --transient --readonly
|
||||
--automount)
|
||||
--automount --auto-mount-point)
|
||||
_get_excluded_items "${items[@]}"
|
||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user