From 1c5695c9c59a230308ace5c9fefef0f8a1dbae0b Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Fri, 4 Apr 2025 15:37:16 +0200 Subject: [PATCH] Fix. --- testing/home/desktop/.local/bin/borgplom | 26 +++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/testing/home/desktop/.local/bin/borgplom b/testing/home/desktop/.local/bin/borgplom index c365cd1..1ac2ce2 100755 --- a/testing/home/desktop/.local/bin/borgplom +++ b/testing/home/desktop/.local/bin/borgplom @@ -9,7 +9,7 @@ cd $(dirname "$0") cd - > /dev/null USAGE_DESCRIPTION='Wrapper around certain borgbackup usages.' -USAGE_LINES='COMMAND\nCOMMAND PATH' +USAGE_LINES='COMMAND [ARGUMENT]...' PATH_BORG_CONF_SECURITY="${PATH_BORG_CONF}/security" PATH_BORG_CONF_KEYS="${PATH_BORG_CONF}/keys" @@ -25,9 +25,10 @@ error_exit_with_usage() { error_exit "${1}\n\n$(print_usage)"; } USAGE_INDICES='backup_keys claim help keys orgpull info' _check_args_n() { - _N_MAX_ARGS="$1" - shift 1 - if [ "$#" -lt "${_N_MAX_ARGS}" ]; then + _N_MIN_ARGS="$1" + _N_MAX_ARGS="$2" + shift 2 + if [ "$#" -lt "${_N_MIN_ARGS}" ]; then error_exit_with_usage "missing arguments ($# instead of ${_N_MAX_ARGS})." fi shift "${_N_MAX_ARGS}" @@ -42,7 +43,7 @@ _id_from_file() { head -1 "$1" | cut -d' ' -f2; } USAGE_ARGS_backup_keys='PATH' USAGE_DESC_backup_keys="copy known keys to PATH/, with their repos' server names as filenames" CMDFNC_backup_keys() { - _check_args_n 1 "$@" + _check_args_n 1 1 "$@" _PATH_TARGET_DIR=$(realpath "$1") if [ -e "${_PATH_TARGET_DIR}" ] && [ ! -d "${_PATH_TARGET_DIR}" ]; then error_exit "non-directory at ${_PATH_TARGET_DIR}" @@ -67,7 +68,7 @@ CMDFNC_backup_keys() { USAGE_ARGS_claim='PATH' USAGE_DESC_claim="register file of PATH as key to repo at \"$(location_from_servername SERVERNAME)\", with SERVERNAME the filename portion of PATH" CMDFNC_claim() { - _check_args_n 1 "$@" + _check_args_n 1 1 "$@" _PATH_SOURCE="$1" _ensure_no_overwrite_at() { if [ -f "$1" ]; then @@ -97,14 +98,14 @@ CMDFNC_claim() { USAGE_DESC_help='print this help and exit' CMDFNC_help() { - _check_args_n 0 "$@" + _check_args_n 0 0 "$@" print_usage } USAGE_ARGS_info='SERVER_NAME [ARCHIVE]' -USAGE_DESC_info='run "borg info" against repo in server of SERVER_NAME, optionally only against ARCHIVE; if latter not provided, instead list archives of repo' +USAGE_DESC_info='run "borg info" against repo in server of SERVER_NAME, optionally only against ARCHIVE; if latter not provided, instead list most recent archives of repo' CMDFNC_info() { - _check_args_n 1 "$@" + _check_args_n 1 2 "$@" _TARGET_REPO="$(location_from_servername ${1})" if [ ! -z "$2" ]; then borg info "${_TARGET_REPO}::$2" @@ -128,12 +129,13 @@ CMDFNC_info() { export BORG_PASSPHRASE= done echo "${_INFO}" - borg list "${_TARGET_REPO}" + echo "Most recent archives:" + borg list "${_TARGET_REPO}" | tail -5 } USAGE_DESC_keys='list known repos in ID, key filename, and alleged location' CMDFNC_keys() { - _check_args_n 0 "$@" + _check_args_n 0 0 "$@" _exit_ok() { echo "(none, since directory ${1})" exit 0 @@ -161,7 +163,7 @@ CMDFNC_keys() { USAGE_DESC_orgpull='pull most recent org directory available in repos' CMDFNC_orgpull() { - _check_args_n 0 "$@" + _check_args_n 0 0 "$@" _NAME_ARCHIVE=orgdir # determine server and repo -- 2.30.2