Implement encryptvm subcommand

This commit is contained in:
Shohei YOSHIDA 2022-12-22 21:36:57 +09:00
parent 5ba8f9c405
commit 7ec9280e88
No known key found for this signature in database
GPG Key ID: C9A1BB11BB940CF2
1 changed files with 372 additions and 331 deletions

View File

@ -21,7 +21,7 @@ _virtualbox() {
}
(( $+functions[_vboxmanage] )) ||
_vboxmanage() {
_vboxmanage() {
local context state line expl
local -A opt_args
local ret=1
@ -98,7 +98,7 @@ _virtualbox() {
&& ret=0
;;
(encryptvm)
# TODO
_vboxmanage_encryptvm && ret=0
;;
(cloud)
# TODO
@ -354,7 +354,7 @@ _virtualbox() {
esac
return 0
}
}
(( $+functions[_vboxmanage_commands] )) ||
_vboxmanage_commands() {
@ -414,6 +414,47 @@ _vboxmanage_commands() {
_describe -t subcommands 'subcommand' commands
}
(( $+functions[_vboxmanage_encryptvm] )) ||
_vboxmanage_encryptvm() {
local ret=1
_arguments -C \
'1: :_vboxmachines' \
'2: :(setencryption checkpassword addpassword removepassword)' \
'*:: :->arg' \
&& ret=0
case $state in
(arg)
local subcommand=$words[2]
if (( $+functions[_vboxmanage_encryptvm_${subcommand}] )); then
compset -n 2
_vboxmanage_encryptvm_${subcommand} && ret=0
else
_arguments '*: :_files' && ret=0
fi
;;
esac
return $ret
}
(( $+functions[_vboxmanage_encryptvm_setencryption] )) ||
_vboxmanage_encryptvm_setencryption() {
_arguments -C \
'--cipher[specify the new cipher for encryption of the VM]: :(AES-128 AES-256)' \
'--new-password[specify the new password for encryption of the VM]: :_files' \
'--new-password-id[specify the new ID for the password for encryption of the VM]:id' \
'--force[make the system to reencrypt the VM instead of the simple changing the password]'
}
(( $+functions[_vboxmanage_encryptvm_addpassword] )) ||
_vboxmanage_encryptvm_addpassword() {
_arguments \
'--new-password[specify the new password for encryption of the VM]: :_files' \
'--new-password-id[specify the new ID for the password for encryption of the VM]:id'
}
(( $+functions[_vboxheadless] )) ||
_vboxheadless() {
local ret=1