diff options
author | Case Duckworth | 2023-01-08 00:13:30 -0600 |
---|---|---|
committer | Case Duckworth | 2023-01-08 00:13:46 -0600 |
commit | bf6ab0367ee2f2dd3d4149efe9be12a46b02defb (patch) | |
tree | fc466bf613324d43a60585ce080b28aae8dc2b15 | |
parent | Change variable names (diff) | |
download | vienna-bf6ab0367ee2f2dd3d4149efe9be12a46b02defb.tar.gz vienna-bf6ab0367ee2f2dd3d4149efe9be12a46b02defb.zip |
Add yornp (y-or-n-p)
I'm not sure if this flow is really what I want to happen .. is it too easy?
-rwxr-xr-x | vienna | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/vienna b/vienna index ca35c39..03d7451 100755 --- a/vienna +++ b/vienna | |||
@@ -103,6 +103,13 @@ main() { | |||
103 | # to use the default configuration. | 103 | # to use the default configuration. |
104 | log error "Can't find configuration \`$CONFIG'." | 104 | log error "Can't find configuration \`$CONFIG'." |
105 | exit 2 | 105 | exit 2 |
106 | else | ||
107 | print >&2 "I'm not sure this is a \`vienna' site directory." | ||
108 | if yornp "Initialize? (y/N)"; then | ||
109 | initialize | ||
110 | else | ||
111 | yornp "Continue building? (y/N)" || exit 2 | ||
112 | fi | ||
106 | fi | 113 | fi |
107 | # Further argument processing --- pre-build | 114 | # Further argument processing --- pre-build |
108 | preprocess "$@" || shift | 115 | preprocess "$@" || shift |
@@ -298,6 +305,16 @@ print() { | |||
298 | printf '%s\n' "$*" | 305 | printf '%s\n' "$*" |
299 | } | 306 | } |
300 | 307 | ||
308 | yornp() { # yornp PROMPT | ||
309 | printf >&2 '%s \n' "$@" | ||
310 | read -r yn | ||
311 | case "$yn" in | ||
312 | [Nn]*) return 1 ;; | ||
313 | [Yy]*) return 0 ;; | ||
314 | *) return 2 ;; | ||
315 | esac | ||
316 | } | ||
317 | |||
301 | ### File processing | 318 | ### File processing |
302 | 319 | ||
303 | ## Building block functions | 320 | ## Building block functions |