115 lines
2.0 KiB
Bash
Executable File
115 lines
2.0 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
|
|
init)
|
|
if [[ ! -e "${ANDROID_HOME}"/license/android-sdk-license ]]; then
|
|
if ! cp -a "${ANDROID_HOME}"/. /sdk; then
|
|
fail "Unable to copy ${ANDROID_HOME} to /sdk"
|
|
fi
|
|
fi
|
|
echo "AndroidSDK transfered to host bind mount."
|
|
;;
|
|
|
|
seed-project)
|
|
seed-project "${options[@]}"
|
|
exit $?
|
|
;;
|
|
develop)
|
|
project="${1}"
|
|
project_type=$(cat "/projects/${project}/project_type")
|
|
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
|
|
;;
|
|
run)
|
|
project="${1}"
|
|
cd "/projects/${project}"
|
|
project_type=$(cat "/projects/${project}/project_type")
|
|
case "${project_type}" in
|
|
"expo")
|
|
echo "Starting web app in ${project}"
|
|
while true; do npm run web; sleep 5; done
|
|
;;
|
|
"flutter")
|
|
echo "Launching terminal in ${project}"
|
|
/bin/bash
|
|
;;
|
|
esac
|
|
;;
|
|
*bash|shell)
|
|
/bin/bash "${options[@]}"
|
|
exit $?
|
|
;;
|
|
*)
|
|
${command} "${@}"
|
|
;;
|
|
esac
|