diff options
author | Case Duckworth | 2022-09-28 22:39:58 -0500 |
---|---|---|
committer | Case Duckworth | 2022-09-28 22:39:58 -0500 |
commit | 2a5a6161501f51d52c6f7c44d87068bd7b58c208 (patch) | |
tree | 13c5e63bd32081f6f05cf1b59d02d2407379cb9c | |
parent | vienna (diff) | |
download | vienna-2a5a6161501f51d52c6f7c44d87068bd7b58c208.tar.gz vienna-2a5a6161501f51d52c6f7c44d87068bd7b58c208.zip |
add usage
-rwxr-xr-x | vienna | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/vienna b/vienna index f7daabc..e32343d 100755 --- a/vienna +++ b/vienna | |||
@@ -1,10 +1,41 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # vienna --- a tiny, tasty ssg | 2 | # vienna --- a tiny, tasty ssg |
3 | # by C. Duckworth <acdw@acdw.net> | 3 | # by C. Duckworth <acdw@acdw.net> |
4 | # shellcheck disable=1090,2035 | ||
4 | 5 | ||
5 | ### Entry point | 6 | ### Entry point |
6 | 7 | ||
7 | configure() { # configure ARG... | 8 | usage() { |
9 | cat <<EOF | ||
10 | VIENNA: a tiny, tasty ssg | ||
11 | by C. Duckworth <acdw@acdw.net> | ||
12 | |||
13 | USAGE: vienna [-h] | ||
14 | vienna [-C DIR] [-d DOMAIN] [-o DIR] [COMMAND] | ||
15 | |||
16 | FLAGS: | ||
17 | -h view this help | ||
18 | |||
19 | OPTIONS: | ||
20 | -C DIR operate in DIR, instead of \$PWD. | ||
21 | -d DOMAIN use DOMAIN as basis for urls. default: example.com | ||
22 | -o DIR output built site to DIR. default: ./out | ||
23 | |||
24 | PARAMETERS: | ||
25 | clean remove output directory before building | ||
26 | publish publish the site after building. | ||
27 | NOTE: this requires a .vienna.sh file in the site root. | ||
28 | you'll have to define a \`publish' function there. | ||
29 | |||
30 | you can redefine any variables or functions vienna uses in \$VIENNA_CONFIG, | ||
31 | which by default is ./.vienna.sh. vienna uses heredoc-inspired templating, so | ||
32 | you can include shell snippets and variables by doubling the dollar signs. | ||
33 | |||
34 | EOF | ||
35 | exit "${1:-0}" | ||
36 | } | ||
37 | |||
38 | configure() { | ||
8 | ## Set up environment | 39 | ## Set up environment |
9 | DOMAIN="${VIENNA_DOMAIN:-https://www.example.com}" | 40 | DOMAIN="${VIENNA_DOMAIN:-https://www.example.com}" |
10 | TMPD="${VIENNA_TMPD:-/tmp/vienna}" | 41 | TMPD="${VIENNA_TMPD:-/tmp/vienna}" |
@@ -22,11 +53,12 @@ configure() { # configure ARG... | |||
22 | # be overridden by command-line flags. | 53 | # be overridden by command-line flags. |
23 | test -f "$CONFIG" && . "$CONFIG" | 54 | test -f "$CONFIG" && . "$CONFIG" |
24 | ## Parse command line arguments | 55 | ## Parse command line arguments |
25 | while getopts d:C:o: opt; do | 56 | while getopts d:C:o:h opt; do |
26 | case "$opt" in | 57 | case "$opt" in |
27 | C) WORKD="$OPTARG" ;; | ||
28 | d) DOMAIN="$OPTARG" ;; | 58 | d) DOMAIN="$OPTARG" ;; |
59 | C) WORKD="$OPTARG" ;; | ||
29 | o) OUTD="$OPTARG" ;; | 60 | o) OUTD="$OPTARG" ;; |
61 | h) usage 0 ;; | ||
30 | *) exit 1 ;; | 62 | *) exit 1 ;; |
31 | esac | 63 | esac |
32 | done | 64 | done |