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* test*
swap swap
_site/* ./site/*
tmp/ ./tmp/

45
make.sh
View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
rootDir='./tmp/' rootDir='./site/'
targetDir='post/' targetDir='post/'
post() { post() {
@ -22,33 +22,38 @@ post() {
rm -f $full 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 # TODO: use getopts to clean this traesh up a bit
case $1 in while getopts ":srhp:" opt;do
"s") case "$opt" in
cp style.css $rootDir s)
cp style.css $rootDir/$targetDir cp style.css "$rootDir" # root stylesheet
cp style.css "$rootDir/$targetDir" # post stylesheet
exit 0 exit 0
;; ;;
"r") r)
echo 'Building the root pages' # Fix targetDir so that it points to the root of the site output
targetDir='' targetDir=''
post './prebuild/about.md' post './prebuild/about.md'
post './prebuild/links.md' post './prebuild/links.md'
post './prebuild/index.md' post './prebuild/index.md'
exit 0 exit 0
;; ;;
esac p)
for file in ${@:2};do
for file in $@;do #echo $file
post $file post $file
done done
;;
if [ -z $@ ] h)
then _help;;
while read line esac
do done
post $line _help;
done < "${1:-/dev/stdin}"
fi