1
0
James Ketrenos bf4956f5e0 Initial version
Signed-off-by: James Ketrenos <james_git@ketrenos.com>
2024-06-24 16:50:06 -07:00

90 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
script_path=$(dirname "${0}")
. "${script_path}/lib/common"
arguments=(
"h|help#This help text."
)
declare -i parse_error=0
declare command=""
#
# Parse command line arguments
#
if ! parse_arguments "${@}"; then
parse_error=1
fi
#
# Process command line options
#
eval set -- "${opts}"
remaining=$#
while (( $# > 0 )); do
if [[ ${remaining} == 0 ]]; then
fail "case statement is not shifting off values correctly."
fi
remaining=$((remaining-1))
# Uncomment to help debug case statement:
# echo "Processing: \$1='$1' \$2='$2'"
case "${1}" in
-h|--help) # Help / usage
usage_extra="[COMMAND [OPTIONS]]"
default_usage
exit 0
;;
--)
shift
break
;;
esac
shift
done
declare command
declare -a options=()
if (( ${#} > 0 )); then
command="${1}"
shift
options=("${@}")
fi
if [[ "${command}" == "" ]]; then
echo "COMMAND must be supplied." >&2
exit 1
fi
if (( parse_error )); then
exit 1
fi
case "${command}" in
*bash|shell)
/bin/bash "${options[@]}"
exit $?
;;
develop)
project_type="${1}"
project="${2}"
cd "/projects/${project}"
case "${project_type}" in
"expo")
echo "Launching web app in ${project}"
npm run web
;;
"flutter")
echo "Launching terminal in ${project}"
/bin/bash
;;
esac
;;
seed-project)
seed-project "${options[@]}"
exit $?
;;
*)
fail "Invalid command '${command}'"
esac