From 82e2fade6b04de88f33a7674ae3dfe2fb5c65b3f Mon Sep 17 00:00:00 2001 From: gryf Date: Tue, 27 Jul 2021 20:00:50 +0200 Subject: [PATCH] Change approach with getting commands out of help. There are currently two ways for specify available commands in vboxmanage help: Usage: VBoxManage [] [..] 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. --- VBoxManage | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/VBoxManage b/VBoxManage index f6f12cb..4804340 100644 --- a/VBoxManage +++ b/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}) ) @@ -2304,7 +2306,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}) ) ;;