fi
}
-cmd_claim() {
+CMD__claim() {
_check_args_beyond 1 "$@"
_PATH_SOURCE="$1"
_ensure_no_overwrite_at() {
chmod u+rw "${_PATH_TARGET_KEY}" "${_PATH_TARGET_LOCATION}"
}
-cmd_help() {
+CMD__help() {
_check_args_beyond 0 "$@"
_print_usage
}
-cmd_keys() {
+CMD__keys() {
_check_args_beyond 0 "$@"
_exit_ok() {
echo "(none, since directory ${1})"
done
}
-cmd_orgpull() {
+CMD__orgpull() {
_check_args_beyond 0 "$@"
_NAME_ARCHIVE=orgdir
if [ "$#" -lt 1 ]; then
error_exit_with_usage "missing command."
fi
-CMD="$1"
-shift 1
-if [ "${CMD}" = "${CMD_CLAIM}" ]; then
- cmd_claim $@
-elif [ "${CMD}" = "${CMD_HELP}" ]; then
- cmd_help $@
-elif [ "${CMD}" = "${CMD_KEYS}" ]; then
- cmd_keys $@
-elif [ "${CMD}" = "${CMD_ORGPULL}" ]; then
- cmd_orgpull $@
-else
+CMD_FUNC="CMD__$1"
+set +e
+type "${CMD_FUNC}" > /dev/null 2>&1
+RESULT="$?"
+set -e
+if [ ! "${RESULT}" = 0 ]; then
error_exit_with_usage "unknown command: ${1}"
fi
+shift 1
+"${CMD_FUNC}" $@