From f1df47c0bc12b4de71faf6edb71ce3df89a90d53 Mon Sep 17 00:00:00 2001 From: clemtre Date: Mon, 15 Jan 2024 19:11:20 +0100 Subject: [PATCH] fix + does file provided exist check --- signet.sh | 48 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/signet.sh b/signet.sh index 066128b..6b8375a 100755 --- a/signet.sh +++ b/signet.sh @@ -1,12 +1,50 @@ #!/bin/bash -DEST=index.html +# , o _, __|_ , |) +# / \_| / | /|/| |/ | / \_|/\ +# \/ |/\/|/ | |_/|_/|_/o \/ | |/ +# (| + +# - - - - - - - - - - - - - - - - ARGS - - - - - - - - - - - - - - - - - +show_help() { + echo "Usage:" + echo " ./signet.sh BOOKMARKS > index.html" + echo "Options:" + echo " --help Display this help message" + exit 1 +} +if [ "$#" -eq 0 ]; then + echo "Nothing happened, I need a file of bookmarks to process." + show_help +fi + +while [ "$#" -gt 0 ]; do + case "$1" in + --help) + show_help + ;; + -*) + echo "Error: Unknown option: $1" >&2 + show_help + ;; + *) + if [ -f "$1" ]; then + break + else + echo "The file you provided doesn't seam to exist : $1" + exit 1 + fi + ;; + esac + shift +done +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- # I thought about using recutils db from GNU but went back to plain text -#DB=BOOKMARKS.rec -DB=BOOKMARKS +# DB=BOOKMARKS.rec +DB=$1 -cat <<- EOF > $DEST +cat <<- EOF @@ -77,5 +115,3 @@ awk -v RS= ' EOF - -