diff options
author | EuAndreh <eu@euandre.org> | 2022-08-12 18:58:23 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2022-08-12 18:58:23 -0300 |
commit | 81d3e80123e618ee8e9ef5e83104b0826985cb0b (patch) | |
tree | 9213103317d8f46abd15866e8e7634cb83773702 /bin | |
parent | bin/80: Add helper utility (diff) | |
download | dotfiles-81d3e80123e618ee8e9ef5e83104b0826985cb0b.tar.gz dotfiles-81d3e80123e618ee8e9ef5e83104b0826985cb0b.tar.xz |
bin/backup: Make tag optional and script verbose by default
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/backup | 32 |
1 files changed, 12 insertions, 20 deletions
@@ -4,7 +4,7 @@ set -eu usage() { cat <<-'EOF' Usage: - backup [-v] [-C COMMENT] ARCHIVE_TAG + backup -q [-C COMMENT] [ARCHIVE_TAG] backup -h EOF } @@ -14,13 +14,13 @@ help() { Options: - -v enable verbose mode, useful for - interactive sessions + -q disable verbose mode, useful for + non-interactive sessions -C COMMENT the comment text to be attached to the archive -h, --help show this message ARCHIVE_TAG the tag used to create the new - backup (default: "cronjob") + backup (default: "manual") The repository is expected to have been created with: @@ -39,13 +39,13 @@ help() { Examples: - Run backup from cronjob: + Run backup manually: - $ backup cronjob + $ backup Create backup with comment, and verbose mode active: - $ backup -vC 'The backup has a comment' my-backup + $ backup -qC 'The backup has a comment' my-backup EOF } @@ -64,12 +64,12 @@ for flag in "$@"; do esac done -VERBOSE_FLAGS='' +VERBOSE_FLAGS='--verbose --progress' COMMENT='' -while getopts 'vC:h' flag; do +while getopts 'qC:h' flag; do case "$flag" in - v) - VERBOSE_FLAGS='--verbose --progress' + q) + VERBOSE_FLAGS='' ;; C) COMMENT="$OPTARG" @@ -87,16 +87,8 @@ while getopts 'vC:h' flag; do done shift $((OPTIND - 1)) -assert_arg() { - if [ -z "$1" ]; then - printf 'Missing %s\n' "$2" >&2 - usage >&2 - exit 2 - fi -} -ARCHIVE_TAG="${1:-}" -assert_arg "$ARCHIVE_TAG" 'ARCHIVE_TAG' +ARCHIVE_TAG="${1:-manual}" run() { |