Merge pull request #841 from paaguti/master

Add initial natnetwork handling to virtualbox
This commit is contained in:
Shohei YOSHIDA 2022-01-26 08:54:25 +09:00 committed by GitHub
commit 1f1962e867
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 2 deletions

View File

@ -1,4 +1,4 @@
#compdef VBoxManage=vboxmanage VBoxHeadless=vboxheadless #compdef VBoxManage=vboxmanage VBoxHeadless=vboxheadless vboxmanage=vboxmanage
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Description # Description
# ----------- # -----------
@ -21,6 +21,12 @@ _vboxmachines() {
done done
} }
_vboxnatnets() {
vboxmanage list natnetworks | awk -F: '/NetworkName:/{print $2}'| while read natnet; do
_wanted 'natnet' expl 'natnet' compadd $natnet
done
}
# Roughly guess command options # Roughly guess command options
_vboxcommandoptions() { _vboxcommandoptions() {
cmd="$1" cmd="$1"
@ -127,6 +133,7 @@ _vboxmanage() {
'hostonlyif:change the IP configuration of a host-only network interface' 'hostonlyif:change the IP configuration of a host-only network interface'
'dhcpserver:control the DHCP server that is built into VirtualBox' 'dhcpserver:control the DHCP server that is built into VirtualBox'
'extpack:add or remove VirtualBox extension packs' 'extpack:add or remove VirtualBox extension packs'
'natnetwork:add,modify,remove or start NatNetworks'
) )
local context state line expl local context state line expl
@ -143,7 +150,7 @@ _vboxmanage() {
list) list)
_arguments \ _arguments \
'--long' \ '--long' \
':list option:(vms runningvms ostypes hostdvds hostfloppies bridgedifs hostonlyifs dhcpservers hostinfo hostcpuids hddbackends hdds dvds floppies usbhost usbfilters systemproperties extpacks)' ':list option:(vms runningvms ostypes hostdvds hostfloppies bridgedifs hostonlyifs dhcpservers hostinfo hostcpuids hddbackends hdds dvds floppies usbhost usbfilters systemproperties natnetworks extpacks)'
;; ;;
showvminfo) showvminfo)
_arguments \ _arguments \
@ -266,6 +273,16 @@ _vboxmanage() {
'--readonly' \ '--readonly' \
'--automount' '--automount'
;; ;;
natnetwork)
_arguments \
':action:(add modify remove start stop)' \
'--netname:natnet:_vboxnatnets' \
'--dhcp:bool:(on off)' \
'--ipv6:bool:(on off)' \
'--enable' \
'--disable'
;;
esac esac
return 1 return 1
} }