diff options
author | lshprung <lshprung@yahoo.com> | 2021-12-18 09:12:20 -0800 |
---|---|---|
committer | lshprung <lshprung@yahoo.com> | 2021-12-18 09:12:20 -0800 |
commit | df37684e88963e46dbf8d8f2e3e737361697b680 (patch) | |
tree | 43b04c1660575a49399d89dbcebe9ab1ae7bc7e1 | |
parent | d71e8fd114660c1c3dc42f56df5777ba5833ecfc (diff) |
Added --yes flag
-rwxr-xr-x | markdown-to-github-html.sh | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/markdown-to-github-html.sh b/markdown-to-github-html.sh index 1102c36..f320a6e 100755 --- a/markdown-to-github-html.sh +++ b/markdown-to-github-html.sh @@ -7,6 +7,7 @@ CUSTOM_INPUT=0 OUTPUT="/dev/stdout" CUSTOM_OUTPUT=0 COMPILER="marked --gfm" +YES=0 #Set to 1 for --yes flag print_help() { echo "Usage: $NAME [OPTION]... [INPUT]" @@ -40,6 +41,11 @@ while [ $# -gt 0 ]; do CUSTOM_OUTPUT=1 shift 2 ;; + -y | --yes) + PROMPT="y" + YES=1 + shift + ;; *) INPUT="$1" CUSTOM_INPUT=1 @@ -50,8 +56,10 @@ done # Check if overwrite if [ $CUSTOM_OUTPUT -eq 1 ] && [ -e "$OUTPUT" ]; then - echo -n "File $OUTPUT already exists. Overwrite it? [y/N] " - read -r PROMPT + if [ $YES -eq 0 ]; then + echo -n "File $OUTPUT already exists. Overwrite it? [y/N] " + read -r PROMPT + fi if [ "$PROMPT" = "y" ]; then echo -n "" > "$OUTPUT" else @@ -61,8 +69,10 @@ fi # Prompt to download CSS file if not in CWD or same directory as NAME if [ ! -e "github-markdown.css" ] || [ ! -e "$(dirname "$NAME")/github-markdown.css" ]; then - echo -n "Download github-markdown.css to current working directory? [Y/n] " - read -r PROMPT + if [ $YES -eq 0 ]; then + echo -n "Download github-markdown.css to current working directory? [Y/n] " + read -r PROMPT + fi if [ ! "$PROMPT" = "n" ]; then wget "$CSS_LINK" fi |