1
0
mirror of https://github.com/cotes2020/jekyll-theme-chirpy.git synced 2025-12-18 05:41:31 +00:00

Pretty shell format.

This commit is contained in:
Cotes Chung
2020-09-01 14:54:29 +08:00
parent 252e33b502
commit c473771af4
7 changed files with 50 additions and 88 deletions

View File

@@ -20,7 +20,6 @@ SYNC_TOOL=_scripts/sh/sync_monitor.sh
cmd="bundle exec jekyll s -l -o"
realtime=false
_help() {
echo "Usage:"
echo
@@ -35,7 +34,6 @@ _help() {
echo " -r, --realtime Make the modified content updated in real time"
}
_cleanup() {
if [[ -d _site || -d .jekyll-cache ]]; then
jekyll clean
@@ -45,7 +43,6 @@ _cleanup() {
ps aux | grep fswatch | awk '{print $2}' | xargs kill -9 > /dev/null 2>&1
}
_init() {
if [[ -d "${WORK_DIR}/${CONTAINER}" ]]; then
@@ -60,7 +57,6 @@ _init() {
trap _cleanup INT
}
_check_unset() {
if [[ -z ${1:+unset} ]]; then
_help
@@ -68,7 +64,6 @@ _check_unset() {
fi
}
_check_command() {
if [[ -z $(command -v "$1") ]]; then
echo "Error: command '$1' not found !"
@@ -77,7 +72,6 @@ _check_command() {
fi
}
main() {
_init
@@ -85,7 +79,7 @@ main() {
bash _scripts/sh/create_pages.sh
bash _scripts/sh/dump_lastmod.sh
if [[ $realtime = true ]]; then
if $realtime; then
fswatch -0 -e "/\..*" "$WORK_DIR" | xargs -0 -I {} bash "./${SYNC_TOOL}" {} "$WORK_DIR" . &
fi
@@ -93,27 +87,24 @@ main() {
eval "$cmd"
}
while (( $# ))
do
while (($#)); do
opt="$1"
case $opt in
-H|--host)
-H | --host)
_check_unset "$2"
cmd+=" -H $2"
shift # past argument
shift # past value
;;
-P|--port)
-P | --port)
_check_unset "$2"
cmd+=" -P $2"
shift
shift
;;
-b|--baseurl)
-b | --baseurl)
_check_unset "$2"
if [[ "$2" == \/* ]]
then
if [[ "$2" == \/* ]]; then
cmd+=" -b $2"
else
_help
@@ -122,16 +113,16 @@ do
shift
shift
;;
-t|--trace)
-t | --trace)
cmd+=" -t"
shift
;;
-r|--realtime)
-r | --realtime)
_check_command fswatch "http://emcrisostomo.github.io/fswatch/"
realtime=true
shift
;;
-h|--help)
-h | --help)
_help
exit 0
;;
@@ -143,5 +134,4 @@ do
esac
done
main