diff options
author | Case Duckworth | 2022-10-04 22:47:25 -0500 |
---|---|---|
committer | Case Duckworth | 2022-10-04 22:47:25 -0500 |
commit | b76d81b4fff5d1c4587645839262886c5d2f133a (patch) | |
tree | 8469e89d5ced45888d0a522511bf047ad8d8a7a7 | |
parent | move sourcing of config to after changing to workdir (diff) | |
download | vienna-b76d81b4fff5d1c4587645839262886c5d2f133a.tar.gz vienna-b76d81b4fff5d1c4587645839262886c5d2f133a.zip |
add -q and better logic for -c
-rwxr-xr-x | vienna | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/vienna b/vienna index e09427f..0ae7027 100755 --- a/vienna +++ b/vienna | |||
@@ -11,12 +11,14 @@ VIENNA: a tiny, tasty ssg | |||
11 | by C. Duckworth <acdw@acdw.net> | 11 | by C. Duckworth <acdw@acdw.net> |
12 | 12 | ||
13 | USAGE: vienna [-h] | 13 | USAGE: vienna [-h] |
14 | vienna [-C DIR] [-d DOMAIN] [-o DIR] [COMMAND] | 14 | vienna [-q] [-c CONFIG] [-C DIR] [-d DOMAIN] [-o DIR] [COMMAND] |
15 | 15 | ||
16 | FLAGS: | 16 | FLAGS: |
17 | -h view this help | 17 | -h view this help |
18 | -q don't output any diagnostic information | ||
18 | 19 | ||
19 | OPTIONS: | 20 | OPTIONS: |
21 | -c CONFIG source CONFIG instead of \$VIENNA_CONFIG when building | ||
20 | -C DIR operate in DIR, instead of \$PWD. | 22 | -C DIR operate in DIR, instead of \$PWD. |
21 | -d DOMAIN use DOMAIN as basis for urls. default: example.com | 23 | -d DOMAIN use DOMAIN as basis for urls. default: example.com |
22 | -o DIR output built site to DIR. default: ./out | 24 | -o DIR output built site to DIR. default: ./out |
@@ -54,12 +56,18 @@ configure() { | |||
54 | # Logging | 56 | # Logging |
55 | LOG=true | 57 | LOG=true |
56 | ## Parse command line arguments | 58 | ## Parse command line arguments |
57 | while getopts d:C:o:hq opt; do | 59 | while getopts C:c:d:ho:q opt; do |
58 | case "$opt" in | 60 | case "$opt" in |
59 | d) DOMAIN="$OPTARG" ;; | ||
60 | C) WORKD="$OPTARG" ;; | 61 | C) WORKD="$OPTARG" ;; |
61 | o) OUTD="$OPTARG" ;; | 62 | c) |
63 | CONFIG="$OPTARG" | ||
64 | # To error later if a config is specified on the command | ||
65 | # line but doesn't exist. | ||
66 | CONFIG_ARG=1 | ||
67 | ;; | ||
68 | d) DOMAIN="$OPTARG" ;; | ||
62 | h) usage 0 ;; | 69 | h) usage 0 ;; |
70 | o) OUTD="$OPTARG" ;; | ||
63 | q) LOG=false ;; | 71 | q) LOG=false ;; |
64 | *) exit 1 ;; | 72 | *) exit 1 ;; |
65 | esac | 73 | esac |
@@ -94,6 +102,17 @@ main() { | |||
94 | # Prepare | 102 | # Prepare |
95 | cd "$WORKD" || exit 2 | 103 | cd "$WORKD" || exit 2 |
96 | test -f "$CONFIG" && . "$CONFIG" # Source ./.vienna.sh, if it exists. | 104 | test -f "$CONFIG" && . "$CONFIG" # Source ./.vienna.sh, if it exists. |
105 | if test -f "$CONFIG"; then | ||
106 | # Source ./.vienna.sh, if it exists. | ||
107 | . "$CONFIG" | ||
108 | elif test -n "$CONFIG_ARG"; then | ||
109 | # If a -c option was passed on the command line but the file | ||
110 | # doesn't exist, that's an error. If we're just looking for the | ||
111 | # default file, however, there is no error---the user might want | ||
112 | # to use the default configuration. | ||
113 | log "Can't find configuration \`$CONFIG'." | ||
114 | exit 2 | ||
115 | fi | ||
97 | mkdir -p "$OUTD" || exit 2 | 116 | mkdir -p "$OUTD" || exit 2 |
98 | mkdir -p "$TMPD" || exit 2 | 117 | mkdir -p "$TMPD" || exit 2 |
99 | # Build pages | 118 | # Build pages |