From 2a5a6161501f51d52c6f7c44d87068bd7b58c208 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 28 Sep 2022 22:39:58 -0500 Subject: add usage --- vienna | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/vienna b/vienna index f7daabc..e32343d 100755 --- a/vienna +++ b/vienna @@ -1,10 +1,41 @@ #!/bin/sh # vienna --- a tiny, tasty ssg # by C. Duckworth +# shellcheck disable=1090,2035 ### Entry point -configure() { # configure ARG... +usage() { + cat < + +USAGE: vienna [-h] + vienna [-C DIR] [-d DOMAIN] [-o DIR] [COMMAND] + +FLAGS: + -h view this help + +OPTIONS: + -C DIR operate in DIR, instead of \$PWD. + -d DOMAIN use DOMAIN as basis for urls. default: example.com + -o DIR output built site to DIR. default: ./out + +PARAMETERS: + clean remove output directory before building + publish publish the site after building. + NOTE: this requires a .vienna.sh file in the site root. + you'll have to define a \`publish' function there. + +you can redefine any variables or functions vienna uses in \$VIENNA_CONFIG, +which by default is ./.vienna.sh. vienna uses heredoc-inspired templating, so +you can include shell snippets and variables by doubling the dollar signs. + +EOF + exit "${1:-0}" +} + +configure() { ## Set up environment DOMAIN="${VIENNA_DOMAIN:-https://www.example.com}" TMPD="${VIENNA_TMPD:-/tmp/vienna}" @@ -22,11 +53,12 @@ configure() { # configure ARG... # be overridden by command-line flags. test -f "$CONFIG" && . "$CONFIG" ## Parse command line arguments - while getopts d:C:o: opt; do + while getopts d:C:o:h opt; do case "$opt" in - C) WORKD="$OPTARG" ;; d) DOMAIN="$OPTARG" ;; + C) WORKD="$OPTARG" ;; o) OUTD="$OPTARG" ;; + h) usage 0 ;; *) exit 1 ;; esac done -- cgit 1.4.1-21-gabe81