Skip to content
This repository was archived by the owner on Jul 6, 2021. It is now read-only.

Commit 9a74078

Browse files
committed
added --force option and improved error reporting about epoch
1 parent 8f3c098 commit 9a74078

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

check

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ process_cli_args() {
207207
"-${SHORT_NAME[$i]}" | "--${FULL_NAME[$i]}" )
208208
if [[ ! -z "${2+x}" ]]; then
209209
argvalue="$2"
210+
# set true for arguments without value (e.g., '--force')
211+
elif [[ "${ARG_TYPE[$i]}" = "None" ]]; then
212+
argvalue="true"
210213
else
211214
argvalue="None"
212215
err "empty value for variable '--${FULL_NAME[$i]}'"
@@ -222,7 +225,11 @@ process_cli_args() {
222225
ARG_VALUE[$i]="$argvalue"
223226
ARG_IS_GIVEN[$i]="true"
224227
CLI_ARGS_CNT=$(( CLI_ARGS_CNT + 1 ))
225-
shift 2
228+
if [[ "${ARG_TYPE[$i]}" = "None" ]]; then
229+
shift 1
230+
else
231+
shift 2
232+
fi
226233
esac
227234
fi
228235
done
@@ -285,6 +292,8 @@ validate_arg_type() {
285292
err "'$name' = '$value' => is not a '$type' (${re})"
286293
exit 1
287294
fi
295+
elif [[ $type = "None" ]]; then
296+
true
288297
else
289298
err "'$name' = '$value' => unknown argument type, validation error"
290299
exit 1
@@ -826,11 +835,14 @@ update_nodes_json() {
826835
SHORT_DIR="${prev_dir}"
827836

828837
# exit with error if epoch is not given and this is not first run
829-
if [[ "${EPOCH}" = "None" ]]; then
838+
if [[ "${EPOCH}" = "None" ]] && [[ "$FORCE" != "true" ]]; then
830839
echo "${BOLD}ERROR: epoch not given but directory already exist:${RESET}" >&2
831-
echo " ${JSON_REPORTS_DIR}" >&2
832-
echo "to avoid overwriting results of epoch '${BOLD}${prev_epoch}${RESET}', please choice health check epoch with help of option '-e'" >&2
833-
echo "example:" >&2
840+
echo " ${JSON_REPORTS_DIR}" >&2
841+
echo >&2
842+
echo "To avoid overwriting results of epoch '${BOLD}${prev_epoch}${RESET}', please choice health check epoch with help of option '-e'" >&2
843+
echo "or just use ${BOLD}--force${RESET} flag" >&2
844+
echo >&2
845+
echo "Example:" >&2
834846
echo "./${SCRIPT_NAME} ${ALL_ARGS} ${BOLD}-e %NUMBER%${RESET}" >&2
835847
exit 1
836848
fi

resources/cli.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Connection options|s|pg-socket-dir|PGSOCKET|text|optional|PostgreSQL domain sock
1515
Connection options|None|psql-binary|PSQLBINARY|text|optional|psql utility path (default: from $PATH)
1616

1717
Health-check-related options|e|epoch|EPOCH|number|optional|epoch of check (default: 1)
18+
Health-check-related options|None|force|FORCE|None|optional|force epoch 1 ('-e 1')
1819
Health-check-related options|None|project|PROJECT|word|mandatory|project name
1920
Health-check-related options|f|file|FILE|filepath|optional|run a single check from given file
2021

0 commit comments

Comments
 (0)