From ddd9aa4a6e4ffe2cd8456817cd14b81f57163190 Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Sat, 17 Aug 2019 14:23:54 -0700 Subject: [PATCH] switched to getopts in build script --- .gitignore | 4 ++-- make.sh | 63 +++++++++++++++++++++++++++++------------------------- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index ef0869f..f156cf2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,5 @@ test* swap -_site/* -tmp/ +./site/* +./tmp/ diff --git a/make.sh b/make.sh index 254a13a..c23b978 100755 --- a/make.sh +++ b/make.sh @@ -1,5 +1,5 @@ #!/bin/bash -rootDir='./tmp/' +rootDir='./site/' targetDir='post/' post() { @@ -22,33 +22,38 @@ post() { rm -f $full } -[[ -z $rootDir/post/ ]] && mkdir -p $rootDir/post +_help() { + echo 'Options: + -p [postDirectory/*] + -r (build root pages) + -s (copy stylesheets)' +} +mkdir -p "$rootDir/post" -# root and style page cases where we don't want to do anything else -case $1 in - "s") - cp style.css $rootDir - cp style.css $rootDir/$targetDir - exit 0 - ;; - "r") - echo 'Building the root pages' - targetDir='' - post './prebuild/about.md' - post './prebuild/links.md' - post './prebuild/index.md' - exit 0 - ;; -esac - -for file in $@;do - post $file +# TODO: use getopts to clean this traesh up a bit +while getopts ":srhp:" opt;do + case "$opt" in + s) + cp style.css "$rootDir" # root stylesheet + cp style.css "$rootDir/$targetDir" # post stylesheet + exit 0 + ;; + r) + # Fix targetDir so that it points to the root of the site output + targetDir='' + post './prebuild/about.md' + post './prebuild/links.md' + post './prebuild/index.md' + exit 0 + ;; + p) + for file in ${@:2};do + #echo $file + post $file + done + ;; + h) + _help;; + esac done - -if [ -z $@ ] -then - while read line - do - post $line - done < "${1:-/dev/stdin}" -fi +_help;