diff --git a/kvm-install-vm b/kvm-install-vm index 30c738c..49ab350 100755 --- a/kvm-install-vm +++ b/kvm-install-vm @@ -33,11 +33,14 @@ function usage_subcommand () create) cat << EOF NAME - $prog create [OPTIONS] VMNAME + $prog create [COMMANDS] [OPTIONS] VMNAME DESCRIPTION Create a new guest domain. +COMMANDS + help - show this help + OPTIONS -b Bridge (default: virbr0) -c Number of vCPUs (default: 1) @@ -83,12 +86,15 @@ EOF remove) cat << EOF NAME - $prog remove VMNAME + $prog remove [COMMANDS] VMNAME DESCRIPTION Destroys (stops) and undefines a guest domain. This also remove the associated storage pool. +COMMANDS + help - show this help + EXAMPLE $prog remove foo Remove (destroy and undefine) a guest domain. WARNING: This will @@ -520,7 +526,9 @@ function create () if [ "$#" != 1 ] then - printf "Too many options.\n" + printf "Please specify a single host to create.\n" + printf "Run 'kvm-install-vm help create' for usage.\n" + exit 1 else VMNAME=$1 fi @@ -595,8 +603,16 @@ case "${subcommand}" in exit 0 ;; create|remove) - "${subcommand}" "$@" - exit $? + if [[ "${1:-none}" == "none" ]]; then + usage_subcommand "${subcommand}" + exit 1 + elif [[ "$1" =~ ^help$ ]]; then + usage_subcommand "${subcommand}" + exit 1 + else + "${subcommand}" "$@" + exit $? + fi ;; *) echo "not valid"