From 482e106fb4da0ba21969373fe46ee02f831a644b Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Fri, 20 Dec 2013 16:19:46 +0100 Subject: [PATCH] add cli server script --- bin/cli-server | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 bin/cli-server 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 -- 2.30.2