Add usage()
authorCase Duckworth <acdw@acdw.net>
Sun, 24 May 2020 00:45:21 +0000 (19:45 -0500)
committerCase Duckworth <acdw@acdw.net>
Sun, 24 May 2020 00:45:21 +0000 (19:45 -0500)
bollux

diff --git a/bollux b/bollux
index 05c916b..b63e645 100755 (executable)
--- a/bollux
+++ b/bollux
@@ -4,14 +4,36 @@
 # License: MIT
 # Version: -0.7
 
+# set -euo pipefail              # strict mode
+
 ### constants ###
 PRGN="${0##*/}"                # program name
-DLDR="${BOLLUX_DOWNDIR:-.}"    # where to download
-LOGL="${BOLLUX_LOGLEVEL:-3}"   # log level
-MAXR="${BOLLUX_MAXREDIR:-5}"   # max redirects
-PORT="${BOLLUX_PORT:-1965}"    # port number
-PROT="${BOLLUX_PROTO:-gemini}" # protocol
+DLDR="${BOLLUX_DOWNDIR:=.}"    # where to download
+LOGL="${BOLLUX_LOGLEVEL:=3}"   # log level
+MAXR="${BOLLUX_MAXREDIR:=5}"   # max redirects
+PORT="${BOLLUX_PORT:=1965}"    # port number
+PROT="${BOLLUX_PROTO:=gemini}" # protocol
 RDRS=0                         # redirects
+VRSN=-0.7                      # version number
+
+# shellcheck disable=2120
+bollux_usage() {
+       cat <<END_USAGE >&2
+       $PRGN ($VRSN): a bash gemini client
+       usage:
+               $PRGN [-h]
+               $PRGN [-L LVL] [URL]
+       options:
+               -h      show this help
+               -L LVL  set the loglevel to LVL.
+                       Default: $BOLLUX_LOGLEVEL
+                       The loglevel is between 0 and 5, with
+                       lower levels being more dire.
+       parameters:
+               URL     the URL to navigate view or download
+END_USAGE
+       exit "${1:-0}"
+}
 
 # LOGLEVELS:
 # 0 - application fatal error