mirror of
https://github.com/gryf/vboxmanage-bash-completion.git
synced 2025-12-17 11:30:23 +01:00
Change approach with getting commands out of help.
There are currently two ways for specify available commands in vboxmanage help: Usage: VBoxManage [<general option>] <command> [..] Commands: command1 ... command2 ... and: VBoxManage command3 ... VBoxManage command4 ... besides the fact how it is annoying for parsing the output (or lack of having some way for machine readable format for commands), I have treated the latter as a exception from general rule, but lately it slowly moving towards the second form. In this patch it is adapted to also parse second format instead of adding those commands manually. Also, there was missing parameter added for sharedfolder add command.
This commit is contained in:
14
VBoxManage
14
VBoxManage
@@ -486,16 +486,18 @@ _VBoxManage() {
|
|||||||
|
|
||||||
# all possible commands for the VBoxManage
|
# all possible commands for the VBoxManage
|
||||||
opts=$(VBoxManage -q help | \
|
opts=$(VBoxManage -q help | \
|
||||||
egrep -o "^\s\s[a-z]+ " | \
|
grep -E -o "^\s\s[a-z]+ " | \
|
||||||
grep -v VBoxManage | \
|
grep -v VBoxManage | \
|
||||||
awk '{print $1}'| \
|
awk '{print $1}'| \
|
||||||
sort | \
|
sort | \
|
||||||
uniq)
|
uniq)
|
||||||
|
|
||||||
# Add some commands manually, since they are listed differently in
|
# Add commands which are defined as ` VBoxManage commandname ` in a help.
|
||||||
# vboxmanage help.
|
opts="${opts} $(VBoxManage -q help | \
|
||||||
opts="${opts} mediumio debugvm unattended extpack clonevm snapshot
|
grep -E -o '^\s\s[a-zA-Z]+\s[a-z]+' | \
|
||||||
dhcpserver cloudprofile cloud"
|
awk '{print $2}'| \
|
||||||
|
sort | \
|
||||||
|
uniq)"
|
||||||
|
|
||||||
if [[ ${cur} == "-q" || ${COMP_CWORD} -eq 1 ]] ; then
|
if [[ ${cur} == "-q" || ${COMP_CWORD} -eq 1 ]] ; then
|
||||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||||
@@ -2304,7 +2306,7 @@ _VBoxManage() {
|
|||||||
case "${subcommand}" in
|
case "${subcommand}" in
|
||||||
add)
|
add)
|
||||||
items=(--name --hostpath --transient --readonly
|
items=(--name --hostpath --transient --readonly
|
||||||
--automount)
|
--automount --auto-mount-point)
|
||||||
_get_excluded_items "${items[@]}"
|
_get_excluded_items "${items[@]}"
|
||||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||||
;;
|
;;
|
||||||
|
|||||||
Reference in New Issue
Block a user