#!/bin/bash setglobal BALLS_LIB = "$[dirname $0]/../lib" setglobal BALLS_LIB = $[readlink -f $BALLS_LIB] # expand the ../ setglobal mode = $1; shift while getopts 'e:C:' opt { match $opt { with C setglobal BALLS_CONF = $OPTARG with e setglobal BALLS_ENV = $OPTARG with \? echo "Usage: $0 [options]" echo echo 'Options:' echo ' -e the server environment, BALLS_ENV' echo ' default: development' echo echo ' -C path to the balls conf file, BALLS_CONF' echo ' default: ./config/$BALLS_ENV.sh' } } [[ -z "$BALLS_ENV" ]] && setglobal BALLS_ENV = 'development' [[ -z "$BALLS_CONF" ]] && setglobal BALLS_CONF = "./config/$BALLS_ENV.sh" source "$BALLS_CONF" source $BALLS_LIB/balls.sh match $mode { with server balls::$mode with * echo "unknown" }