Added discardstate command

This commit is contained in:
2015-04-09 21:22:11 +02:00
parent 7df3e8c621
commit 20e85255c1
2 changed files with 31 additions and 2 deletions

1
README
View File

@@ -18,6 +18,7 @@ Current version of script was written and tested against VBoxManage in version
- createvm - createvm
- debugvm - debugvm
- dhcpserver - dhcpserver
- discardstate
- list - list
- showhdinfo - showhdinfo
- showvminfo - showvminfo

View File

@@ -7,7 +7,6 @@
# #
# [1] Sebastian T. Hafner <sonix@own-hero.net> # [1] Sebastian T. Hafner <sonix@own-hero.net>
# #
# [ ] discardstate
# [ ] export # [ ] export
# [ ] extpack # [ ] extpack
# [ ] getextradata # [ ] getextradata
@@ -110,6 +109,28 @@ _VBoxManage() {
done done
} }
_vms_state_comp() {
local command=$1
local cur=$2
local vms
local item
compopt -o filenames
vms=$(VBoxManage list vms -l | \
egrep '^Name|State' | \
egrep -B1 'State:\s+saved' | \
grep Name |sed 's/Name:\s\+//' | \
tr '\n' '|' | \
sed 's/|$//' | \
sed 's/"//g')
IFS='|' read -ra vms <<< "$vms"
for item in "${vms[@]}"
do
[[ ${item^^} == ${cur^^}* ]] && COMPREPLY+=("$item")
done
}
_list_comp() { _list_comp() {
local cur=$1 local cur=$1
local list local list
@@ -348,7 +369,10 @@ _VBoxManage() {
case "${cmd}" in case "${cmd}" in
adoptstate) adoptstate)
_vms_comp vms ${cur} _find_item_name 2
COMPREPLY=()
[[ -z "${name}" ]] &&
_vms_state_comp ${cur}
;; ;;
bandwidthctl) bandwidthctl)
local items=(add set remove list) local items=(add set remove list)
@@ -734,6 +758,10 @@ _VBoxManage() {
fi fi
;; ;;
discardstate) discardstate)
_find_item_name 2
COMPREPLY=()
[[ -z "${name}" ]] &&
_vms_state_comp ${cur}
;; ;;
"export") "export")
;; ;;