switched to getopts in build script

This commit is contained in:
shockrahwow 2019-08-17 14:23:54 -07:00
parent e4d84c18f1
commit ddd9aa4a6e
2 changed files with 36 additions and 31 deletions

4
.gitignore vendored
View File

@ -2,5 +2,5 @@
test*
swap
_site/*
tmp/
./site/*
./tmp/

45
make.sh
View File

@ -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
# 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")
echo 'Building the root pages'
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
;;
esac
for file in $@;do
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;