Browse Source

add watch and fix flags on serve command

encrypt 3 years ago
parent
commit
4c23f6e384
1 changed files with 15 additions and 2 deletions
  1. 15 2
      boh

+ 15 - 2
boh

@@ -20,6 +20,7 @@ boh_help() {
     echo "  build, b             Build your pages"
     echo "  serve, server, s     Serve your pages locally"
     echo "  new                  Creates boh basic stuff"
+    echo "  watch                Wait for changes then rebuild all the things"
 }
 
 boh_new() {
@@ -40,7 +41,7 @@ EOF
 
 boh_serve() {
     cd "$destination_dir"
-    python2 -m SimpleHTTPServer
+    python2 -m SimpleHTTPServer $@
 }
 
 boh_check() {
@@ -100,6 +101,15 @@ boh_build() {
     echo "Yay!"
 }
 
+boh_watch() {
+    echo "watching $(pwd)"
+    inotifywait -r -q -e close_write -m --exclude _site/ $(pwd) | while read events
+    do
+	boh_check
+	boh_build
+    done
+}
+
 ## defaults
 source_dir="./"
 destination_dir="./_site"
@@ -143,11 +153,14 @@ case $command in
 	boh_new
 	;;
     "serve"|"server"|"s")
-	boh_serve
+	boh_serve $@
 	;;
     "publish")
 	type boh_publish &> /dev/null && { boh_publish; }
 	;;
+    "watch")
+	boh_watch
+	;;
     *)
 	boh_help
 	;;