cros_workon: automatically display usage when given bad arguments

I find this easier to work with.

BUG=None
TEST=`cros_workon` displays usage now before showing error
TEST=`cros_workon-x86-alex` displays usage now before showing error

Change-Id: Id307bfe34e4aea4b7da62f383bd543ddbef4ccc6
Reviewed-on: https://gerrit.chromium.org/gerrit/15511
Reviewed-by: David James <davidjames@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Mike Frysinger 2012-02-08 14:13:20 -05:00 committed by David James
parent e7293bb80c
commit 3482223936

View File

@ -47,9 +47,12 @@ shift
# there's no way to override.
[ -n "${FLAGS_board}" ] && [ "${FLAGS_host}" = ${FLAGS_TRUE} ] && \
FLAGS_board="" # kill board
[ -z "${FLAGS_board}" ] && [ "${FLAGS_host}" = ${FLAGS_FALSE} ] && \
[ "${WORKON_CMD}" != "list-all" ] && \
if [ -z "${FLAGS_board}" ] && \
[ "${FLAGS_host}" = ${FLAGS_FALSE} ] && \
[ "${WORKON_CMD}" != "list-all" ]; then
flags_help
die "You must specify either --host or --board="
fi
if [ -n "${FLAGS_board}" ]; then
BOARD_DIR=/build/"${FLAGS_board}" # --board specified
@ -353,5 +356,8 @@ case ${WORKON_CMD} in
show_workon_ebuilds ${BOARD_KEYWORD} ;;
list-all) show_all_live_ebuilds ;;
iterate) ebuild_iterate "${ATOM_LIST}" ;;
*) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;;
*)
flags_help
die "$(basename $0): command '${WORKON_CMD}' not recognized"
;;
esac