From bf6ab0367ee2f2dd3d4149efe9be12a46b02defb Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 8 Jan 2023 00:13:30 -0600 Subject: Add yornp (y-or-n-p) I'm not sure if this flow is really what I want to happen .. is it too easy? --- vienna | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/vienna b/vienna index ca35c39..03d7451 100755 --- a/vienna +++ b/vienna @@ -103,6 +103,13 @@ main() { # to use the default configuration. log error "Can't find configuration \`$CONFIG'." exit 2 + else + print >&2 "I'm not sure this is a \`vienna' site directory." + if yornp "Initialize? (y/N)"; then + initialize + else + yornp "Continue building? (y/N)" || exit 2 + fi fi # Further argument processing --- pre-build preprocess "$@" || shift @@ -298,6 +305,16 @@ print() { printf '%s\n' "$*" } +yornp() { # yornp PROMPT + printf >&2 '%s \n' "$@" + read -r yn + case "$yn" in + [Nn]*) return 1 ;; + [Yy]*) return 0 ;; + *) return 2 ;; + esac +} + ### File processing ## Building block functions -- cgit 1.4.1-21-gabe81