diff --git a/pbc b/pbc index 511d2be..83d8014 100755 --- a/pbc +++ b/pbc @@ -1,24 +1,46 @@ #!/usr/bin/env bash function usage() { + full=${1:-false} cat <&2 && return 254 + echo "Commands of proxmox-backup-client:" + echo + "$PBC" help | tail -n +3 + echo + return $? } function pbc-version() { @@ -189,9 +211,6 @@ while [ -n "$1" ]; do shift if [ -z "$action" ]; then case "$opt" in - backup|backup-cron|list|snapshot-list|catalog-shell|mount|install) - action=$opt - ;; -c|--config) cfgfile=$1 shift @@ -201,17 +220,34 @@ while [ -n "$1" ]; do usage exit 0 ;; - *) + -H|--full-help) + full_usage + exit 0 + ;; + -*) + echo "Error: invalid option: $opt" >&2 + echo usage exit 255 ;; + *) + action=$opt + ;; esac elif [ "$action" == "install" ]; then case "$opt" in -u|--update) args+=('true') ;; + -*) + echo "Error: invalid option: $opt" >&2 + echo + usage + exit 255 + ;; *) + echo "Error: invalid argument: $opt" >&2 + echo usage exit 255 ;; @@ -321,7 +357,7 @@ case "$action" in read -r target [ -d "$target" ] && break echo -e "\nError: $target: no such directory\n" >&2 - target='' + target='' done elif [ ! -d "$target" ]; then echo "Error: $target: no such directory" >&2 @@ -362,7 +398,6 @@ case "$action" in echo "$action successful!" ;; *) - usage - exit 1 + "$PBC" "$action" "${args[@]}" || exit $? ;; esac