From 7838b0c6e0870b27e33eab62c0b545f5e0a1e631 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Thu, 26 Mar 2020 02:35:30 -0600 Subject: [PATCH] preflight checks --- .vscode/numbered-bookmarks.json | 18 +----------------- borghelper.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/.vscode/numbered-bookmarks.json b/.vscode/numbered-bookmarks.json index 28d6e94..4c08963 100644 --- a/.vscode/numbered-bookmarks.json +++ b/.vscode/numbered-bookmarks.json @@ -1,19 +1,3 @@ { - "bookmarks": [ - { - "fsPath": "$ROOTPATH$/borghelper.sh", - "bookmarks": [ - -1, - 8, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1 - ] - } - ] + "bookmarks": [] } \ No newline at end of file diff --git a/borghelper.sh b/borghelper.sh index beac911..c5a6ce6 100644 --- a/borghelper.sh +++ b/borghelper.sh @@ -101,3 +101,29 @@ while [ $# -gt 0 ]; do shift done + +### check parameter validity + +# no operation +if [ -z "$operation" ]; then + consoleError 1 'Nothing to do!' +fi + +# list without archive +if [ "$operation" = 'list' ] && [ -z "$archiveName" ]; then + consoleError 1 "List operation requested but no archive name provided. Please use '--list-all' for a list of all available archives." +fi + +# restore with no path +if [ "$operation" = 'restore' ] && [ -z "$restorePath" ]; then + consoleError 1 "Restore operation requested but no restore path provided." +# restore with no archive +elif [ "$operation" = 'restore' ] && [ -z "$archiveName" ]; then + consoleError 1 "Restore operation requested but no archive name provided." +fi + +# file provided but no archive +if [ "$fileName" ] && [ -z "$archiveName" ]; then + consoleError 1 "Filename specified without an associated archive name." +fi +