Skip to content

Commit

Permalink
build.sh: robust option handling
Browse files Browse the repository at this point in the history
Adds help, long options, production-mode switches (which may cancel
development mode.)
  • Loading branch information
sapphirecat committed Oct 8, 2023
1 parent 6a5ad8c commit 12275ab
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,32 @@ set -eu

cd "$(dirname "$0")"

usage() {
cat <<EOF
Usage: $(basename "$0") [-d]
Runs the build, processing src/ to create dist/.
Options (last wins):
-d|--dev: Development mode (default is production)
-p|--prod: Production mode
EOF
exit 0
}

mode=build
case "${1:-.}" in
-d) mode=dev ;;
esac
while [ $# -gt 0 ] ; do
case "${1:-}" in
-d|--dev) mode=dev ;;
-p|--prod) mode=build ;;
-h|--help) usage ;;
--) shift ; break ;;
*) echo "Unrecognized argument: ${1:-}" >&2 ;;
esac
shift
done

# make sure we are probably in a reasonable place
if [ ! -d src ] ; then
Expand Down

0 comments on commit 12275ab

Please sign in to comment.