feat(obd): Unknown commands should exit with non-zero code

This commit is contained in:
LINxiansheng
2023-04-10 06:18:16 +00:00
committed by ob-robot
parent 7b5fd78505
commit ce45c64bf6

View File

@ -11,7 +11,7 @@ tag="latest"
current_path=$(pwd) current_path=$(pwd)
if [[ "$current_path" != "$BASE_DIR/tools/deploy" ]] if [[ "$current_path" != "$BASE_DIR/tools/deploy" ]]
then then
echo "切换至路径[$BASE_DIR/tools/deploy]" echo "Switching basedir to [$BASE_DIR/tools/deploy]..."
cd $BASE_DIR/tools/deploy || exit 1 cd $BASE_DIR/tools/deploy || exit 1
fi fi
@ -538,9 +538,9 @@ function graph {
function help_info { function help_info {
echo """ echo """
Usage: $entrance <commond> [options] Usage: $entrance <command> [options]
Available commonds: Available commands:
prepare [-p DATA_PATH -h HOST] Prepare for deployment. prepare [-p DATA_PATH -h HOST] Prepare for deployment.
deploy -c YAML_CONF [-n DEPLOY_NAME] Deploy a cluster by a deploy yaml file. Default deploy name will be the name of yaml file. deploy -c YAML_CONF [-n DEPLOY_NAME] Deploy a cluster by a deploy yaml file. Default deploy name will be the name of yaml file.
@ -590,7 +590,7 @@ Options:
function main() { function main() {
entrance=${OBD_SH_ENTRANCE:-obd.sh} entrance=${OBD_SH_ENTRANCE:-obd.sh}
variables_parpare variables_parpare
commond="$1" command="$1"
shift shift
extra_args="" extra_args=""
while true; do while true; do
@ -598,7 +598,7 @@ function main() {
-v ) VERBOSE_FLAG='-v'; set -x; shift ;; -v ) VERBOSE_FLAG='-v'; set -x; shift ;;
--with-local-obproxy) WITH_LOCAL_PROXY="1";SKIP_COPY="1"; shift ;; --with-local-obproxy) WITH_LOCAL_PROXY="1";SKIP_COPY="1"; shift ;;
-c | --config ) -c | --config )
if [[ $commond == "deploy" || $commond == "redeploy" || $commond == "mysqltest" ]] if [[ $command == "deploy" || $command == "redeploy" || $command == "mysqltest" ]]
then then
YAML_CONF="$2" YAML_CONF="$2"
shift 2 shift 2
@ -644,10 +644,13 @@ function main() {
then then
obd env set OBD_DEPLOY_BASE_DIR "$DEPLOY_PATH" obd env set OBD_DEPLOY_BASE_DIR "$DEPLOY_PATH"
fi fi
case $commond in case $command in
-V | --version) -V | --version)
obd --version obd --version
;; ;;
-h | --help)
help_info
;;
prepare) prepare)
[[ "$SKIP_COPY" == "" ]] && copy_sh [[ "$SKIP_COPY" == "" ]] && copy_sh
generate_config generate_config
@ -739,7 +742,9 @@ function main() {
graph graph
;; ;;
*) *)
echo "Unknown command: $command"
help_info help_info
exit 1
;; ;;
esac esac
} }