doc: add details for commands + verbosity

This commit is contained in:
Glenn Y. Rolland 2022-01-26 17:03:07 +01:00
parent 69eeba6311
commit da505d456b

View file

@ -4,9 +4,20 @@
# Set defaults # Set defaults
BASEDIR="$(pwd)" BASEDIR="$(pwd)"
ACTION="watch" ACTION="watch"
VERBOSITY="0"
DOCKER_IMAGE=glenux/teaching-boilerplate:latest DOCKER_IMAGE=glenux/teaching-boilerplate:latest
DOCKER_OPT_TTY="-t" DOCKER_OPT_TTY="-t"
gxt_usage() {
echo "Usage: $0 [options]"
echo ""
echo "-d, --data-dir DIR Content directory"
echo "-a, --action ACTION Action (watch, build, shell, etc.)"
echo "-t, --tty Enable TTY mode (needed for shell)"
echo "-v, --verbose Enable verbosity"
echo "-h, --help Show this help"
}
# Parse arguments # Parse arguments
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
ARG="${1:-}" ARG="${1:-}"
@ -16,6 +27,14 @@ while [ $# -gt 0 ]; do
# echo "DEBUG: ARG=$ARG OPT=$OPT" # echo "DEBUG: ARG=$ARG OPT=$OPT"
case "$ARG" in case "$ARG" in
-a|--action)
shift # argument requires a parameter
if [ -z "$OPT" ]; then
>&2 echo "ERROR: missing argument for --action"
exit 1
fi
ACTION="$OPT"
;;
-d|--data-dir) -d|--data-dir)
shift # argument requires a parameter shift # argument requires a parameter
if [ -z "$OPT" ]; then if [ -z "$OPT" ]; then
@ -28,26 +47,18 @@ while [ $# -gt 0 ]; do
fi fi
BASEDIR="$(cd "$OPT" && pwd)" BASEDIR="$(cd "$OPT" && pwd)"
;; ;;
-a|--action) -h|--help)
shift # argument requires a parameter >&2 gxt_usage
if [ -z "$OPT" ]; then exit 0
>&2 echo "ERROR: missing argument for --action"
exit 1
fi
ACTION="$OPT"
;; ;;
-T|--no-tty) -T|--no-tty)
DOCKER_OPT_TTY="" DOCKER_OPT_TTY=""
;; ;;
-h|--help) -v|--verbosity)
echo "Usage: $0 [options]" VERBOSITY="$((VERBOSITY+1))"
echo ""
echo "-d, --data-dir DIR Content directory"
echo "-a, --action ACTION Action (watch, build, shell, etc.)"
echo "-t, --tty Enable TTY mode (needed for shell)"
echo "-h, --help Show this help"
;; ;;
*) *)
>&2 gxt_usage
>&2 echo "ERROR: unknown option '$ARG'" >&2 echo "ERROR: unknown option '$ARG'"
exit 1 exit 1
;; ;;
@ -80,7 +91,9 @@ if [ -d "$BASEDIR/docs" ]; then
DOCKER_OPT_MKDOCS_PORT="-p 5100:5100" DOCKER_OPT_MKDOCS_PORT="-p 5100:5100"
fi fi
set -x if [ "$VERBOSITY" -gt 0 ]; then
set -x
fi
docker run -i $DOCKER_OPT_TTY \ docker run -i $DOCKER_OPT_TTY \
--shm-size=1gb \ --shm-size=1gb \
-e "EXT_UID=$(id -u)" \ -e "EXT_UID=$(id -u)" \
@ -94,7 +107,9 @@ docker run -i $DOCKER_OPT_TTY \
$DOCKER_OPT_MKDOCS_PORT \ $DOCKER_OPT_MKDOCS_PORT \
$DOCKER_OPT_MARP_PORT \ $DOCKER_OPT_MARP_PORT \
"$DOCKER_IMAGE" "$ACTION" "$DOCKER_IMAGE" "$ACTION"
set +x if [ "$VERBOSITY" -gt 0 ]; then
set +x
fi
# TODO: ask current user permissions # TODO: ask current user permissions
# TODO: fix permissions on generated files # TODO: fix permissions on generated files