From: Michael Wallner Date: Fri, 20 Dec 2013 15:19:46 +0000 (+0100) Subject: add cli server script X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=482e106fb4da0ba21969373fe46ee02f831a644b;p=mdref%2Fmdref add cli server script --- diff --git a/bin/cli-server b/bin/cli-server new file mode 100755 index 0000000..15b4b55 --- /dev/null +++ b/bin/cli-server @@ -0,0 +1,47 @@ +#!/bin/bash + +# record working dir +OWD=$(pwd) + +# chdir to docroot +cd $(dirname $0)/../public + +function addrefpath { + path="$1" + if test ${path:0:1} != "/" + then + REFPATH="$OWD/$path$REFPATH" + else + REFPATH="$path$REFPATH" + fi +} + +# override REFPATH +if test $# -gt 0; then + REFPATH="" + addrefpath "$1" + shift + while test $# -gt 0; do + addrefpath "$1:" + shift + done +fi + +if test -z "$REFPATH" +then + printf "Usage:\n\t%s [refpath] ...\n\n" "$(basename $0)" + printf "Parameters:\n" + printf "\trefpath path to a markdown reference tree or a colon separated\n" + printf "\t list of those (optional, multiple)\n\n" + printf "Environment:\n" + printf "\tREFPATH colon separated list of refpaths\n\n" + printf "At least one refpath must be given, either through the environment " + printf "with REFPATH or as command line argument.\n\n" + exit 1 +fi + +export REFPATH + +for p in {8000..8100}; do + php -S localhost:$p -t . index.php && break +done