switched to getopts in build script
This commit is contained in:
parent
e4d84c18f1
commit
ddd9aa4a6e
4
.gitignore
vendored
4
.gitignore
vendored
@ -2,5 +2,5 @@
|
||||
test*
|
||||
|
||||
swap
|
||||
_site/*
|
||||
tmp/
|
||||
./site/*
|
||||
./tmp/
|
||||
|
63
make.sh
63
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;
|
||||
|
Loading…
Reference in New Issue
Block a user