use case show_env is listed and not trigered, but create_target_group is remove from action list, but still in the if .. elif .. fi
WARNING: this bash eval at true
v=''
if $v ; then echo pipo; fi
# will output pipo
example cli (snipet not tested)
# Usage:
# ./run_migration.sh init
# ./run_migration.sh add DESCRIPTION MIGRATION_FILE [--target_group=TARGET_GROUP]
# ./run_migration.sh list
# ./run_migration.sh run MIGRATION_JOBID
# ./run_migration.sh delete MIGRATION_JOBID
# ./run_migration.sh view MIGRATION_JOBID
# ./run_migration.sh list_target_groups
# ./run_migration.sh list_available_target
# ./run_migration.sh list_databases [--server=SERVER_NAME] [--join]
# ./run_migration.sh show_env
# ./run_migration.sh -h
#
SCRIPT_DIR=$(dirname $0)
PATH=$SCRIPT_DIR:$PATH
# auto parse the script header and export ${ARGS[]} mapped argument
# docopts do all the magic parsing argument as defined in the doc header.
source docopts.sh --auto "$@"
## ======================================== main switch for arguments
if ${ARGS[add]}
then
add_migration "${ARGS[DESCRIPTION]}" "${ARGS[MIGRATION_FILE]}" "${ARGS[--target_group]}"
elif ${ARGS[run]}
then
if exec_migration_job ${ARGS[MIGRATION_JOBID]}
then
echo "migration in progress"
exit 0
fi
elif ${ARGS[list]}
then
list_migration
elif ${ARGS[delete]}
then
delete_migration_job "${ARGS[MIGRATION_JOBID]}"
elif ${ARGS[view]}
then
view_migration "${ARGS[MIGRATION_JOBID]}"
elif ${ARGS[list_target_groups]}
then
list_target_groups
elif ${ARGS[create_target_group]}
then
create_target_group "${ARGS[TARGET_GROUP]}" "${ARGS[SERVER_NAME]}" DATABASE
elif ${ARGS[list_databases]}
then
list_databases
elif ${ARGS[list_available_target]}
then
list_available_target
else
echo "error: unknown action"
fi
Could we provide something like:
case ${ARGS[docopts_ACTIONS]} in
add)
;;
run)
;;
list)
;;
*)
;;
esac
use case
show_env
is listed and not trigered, butcreate_target_group
is remove from action list, but still in theif .. elif .. fi
WARNING: this bash eval at
true
example cli (snipet not tested)
Could we provide something like: