From 5db7a2bae10fa1d0d7c3bc57018202c2de3c28db Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Thu, 9 Jun 2016 10:17:59 +0000 Subject: [PATCH] Print usage on --help argument to any command --- weave | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/weave b/weave index b09bd849..18b69d44 100755 --- a/weave +++ b/weave @@ -108,6 +108,13 @@ usage() { exit 1 } +handle_help_arg() { + if [ "$1" = "--help" ] ; then + usage_no_exit + exit 0 + fi +} + docker_sock_options() { # Pass through DOCKER_HOST if it is a Unix socket; # a TCP socket may be secured by TLS, in which case we can't use it @@ -325,12 +332,11 @@ check_docker_version [ "$1" = "--local" ] && shift 1 && IS_LOCAL=1 -if [ "$1" = "--help" -o "$1" = "help" ] ; then - # "--help|help" are special because we always want to process them - # at the client end. - usage_no_exit - exit 0 -elif [ "$1" = "version" -a -z "$IS_LOCAL" ] ; then +# "--help|help" are special because we always want to process them +# at the client end. +handle_help_arg "$1" || handle_help_arg "--$1" + +if [ "$1" = "version" -a -z "$IS_LOCAL" ] ; then # non-local "version" is special because we want to show the # version of the script executed by the user rather than what is # embedded in weaveexec. @@ -352,6 +358,7 @@ elif [ "$1" = "run" -a -z "$IS_LOCAL" ] ; then # we can't rely on our baked-in docker to support those arguments. shift 1 + handle_help_arg "$1" [ "$1" = "--without-dns" ] || DNS_ARGS=$(exec_remote dns-args "$@" || true) shift $(dns_arg_count "$@") @@ -1863,6 +1870,8 @@ deprecation_warnings() { COMMAND=$1 shift 1 +handle_help_arg "$1" + case "$COMMAND" in setup) for img in $IMAGE $EXEC_IMAGE $PLUGIN_IMAGE $WEAVEDB_IMAGE ; do