paritybit.ca

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit dab6eeff1b4fe313d6b04898332d1877d6427ba7
parent 6248dac2e0083876c61bde01ca2b65f9a72621ce
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Thu, 11 Jun 2020 16:24:47 -0400

Add command line options to compile script

These are needed to allow turning off auto-uploading so that it is not
perfomed from the publish script which has its own auto-upload feature.

Fleshed out these options so that auto-uploading and strict compilation
can be turned on or off from the command line regardless of the
configuration of the script.

Diffstat:
Mcompile | 46+++++++++++++++++++++++++++++++++++++++-------
1 file changed, 39 insertions(+), 7 deletions(-)

diff --git a/compile b/compile @@ -48,6 +48,7 @@ YELLOW="\033[0;33m" siteName="paritybit.ca" # Set to "false" to disable auto-upload autoUpload="true" +# Set to "true" to enable pandoc's strict markdown compilation # Where to upload files remote="paritybit.ca:uploads/" # Where md files are @@ -62,13 +63,6 @@ mkdir -p "$cssDir" buildDir="build/" mkdir -p "$buildDir" -if [ "$1" = "-s" ]; then - strictMode="true" - shift -else - strictMode="false" -fi - # Prints the message passed as the 1st argument in red. print_error_msg() { @@ -234,6 +228,44 @@ set_html_toc() </section>" "$outputFile" } +# Read and parse command line flags +while test $# -gt 0; do + case "$1" in + -h|--help) + echo "compile - generate web pages from markdown files" + echo "" + echo "usage: compile [options] files" + echo "" + echo "options:" + echo "-h|--help show brief help" + echo "-l|--loose use pandoc's default markdown compilation" + echo "-s|--strict use strict markdown compilation" + echo "-a|--auto-upload auto-upload generated files" + echo "-n|--no-auto-upload do not auto-upload the generated files" + exit 0 + ;; + -l|--loose) + strictMode="false" + shift + ;; + -s|--strict) + strictMode="true" + shift + ;; + -n|--no-auto-upload) + autoUpload="false" + shift + ;; + -a|--auto-upload) + autoUpload="true" + shift + ;; + --|*) + break + ;; + esac +done + for file in "$@"; do if [ ! -f "$file" ]; then print_error_msg "ERROR: $file not found or is not a file."