}
# commands
-COMMANDS='claim help keys orgpull'
+COMMANDS='backup_keys claim help keys orgpull'
-_check_args_beyond() {
+_check_args_n() {
_N_MAX_ARGS="$1"
+ if [ "$#" -lt "${_N_MAX_ARGS}" ]; then
+ error_exit "missing arguments ($# instead of ${_N_MAX_ARGS}."
+ fi
shift $(calc "${_N_MAX_ARGS} + 1" | cut -f2)
if [ "$#" -gt 0 ]; then
- _MSG="unexpected arguments beyond command: $@"
+ _MSG="unexpected arguments beyond expected number: $@"
error_exit "${_MSG}"
fi
}
HELP_ARGS_backup_keys=' PATH'
HELP_DESC_backup_keys="copy known keys to PATH/, with their repos' server names as filenames"
CMDFNC_backup_keys() {
- _check_args_beyond 1 "$@"
+ _check_args_n 1 "$@"
_PATH_TARGET_DIR="$1"
if [ -e "${_PATH_TARGET_DIR}"] && [ ! -d "${_PATH_TARGET_DIR}" ]; then
error_exit "non-directory at ${_PATH_TARGET_DIR}"
HELP_ARGS_claim=' PATH'
HELP_DESC_claim="register file of PATH as key to repo at \"$(servername_to_location SERVERNAME)\", with SERVERNAME the filename portion of PATH"
CMDFNC_claim() {
- _check_args_beyond 1 "$@"
+ _check_args_n 1 "$@"
_PATH_SOURCE="$1"
_ensure_no_overwrite_at() {
if [ -f "$1" ]; then
HELP_DESC_help='print this help and exit'
CMDFNC_help() {
- _check_args_beyond 0 "$@"
+ _check_args_n 0 "$@"
_print_usage
}
HELP_DESC_keys='list known repos in ID, key filename, and alleged location'
CMDFNC_keys() {
- _check_args_beyond 0 "$@"
+ _check_args_n 0 "$@"
_exit_ok() {
echo "(none, since directory ${1})"
exit 0
HELP_DESC_orgpull='pull most recent org directory available in repos'
CMDFNC_orgpull() {
- _check_args_beyond 0 "$@"
+ _check_args_n 0 "$@"
_NAME_ARCHIVE=orgdir
# determine server and repo