From af4d361f6ac90864ea05dadc98cbe50c4a565e9b Mon Sep 17 00:00:00 2001 From: James Barnett Date: Mon, 7 Nov 2016 12:01:34 -0600 Subject: [PATCH] add commandline description; initial help flag (#3) --- bin/snap-sync | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/bin/snap-sync b/bin/snap-sync index 98a2ed1..11b2bba 100755 --- a/bin/snap-sync +++ b/bin/snap-sync @@ -9,7 +9,33 @@ set -e -declare -r description="latest incremental backup" +while [[ $# -gt 0 ]]; do + key="$1" + case $key in + -d|--description) + description="$2" + shift + ;; +#TODO -u|--UUID) +# uuid_cmdline="$2" +# shift +# ;; +# TODO: add more + -h|--help) + echo "Usage:" + echo " snap-sync -d 'Snapshot description'" + shift + exit 1 + ;; + *) + echo "Error: unknown option." + exit 1 + ;; + esac + shift +done + +description=${description:-"latest incremental backup"} if [[ $EUID -ne 0 ]]; then printf "Script must be run as root.\n"