diff options
Diffstat (limited to 'apps/compiler/compiler.sh')
-rwxr-xr-x | apps/compiler/compiler.sh | 74 |
1 files changed, 50 insertions, 24 deletions
diff --git a/apps/compiler/compiler.sh b/apps/compiler/compiler.sh index cb89bfb705..388ad41a32 100755 --- a/apps/compiler/compiler.sh +++ b/apps/compiler/compiler.sh @@ -4,41 +4,67 @@ CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source "$CURRENT_PATH/includes/includes.sh" -function all() { - comp_clean - comp_configure - comp_build -} - function run_option() { - if test "${comp_functions[$1-1]+'test'}"; then + re='^[0-9]+$' + if [[ $1 =~ $re ]] && test "${comp_functions[$1-1]+'test'}"; then ${comp_functions[$1-1]} + elif [ -n "$(type -t comp_$1)" ] && [ "$(type -t comp_$1)" = function ]; then + fun="comp_$1" + $fun else - echo "invalid option" - fi + echo "invalid option, use --help option for the commands list" + fi } -comp_options=("Clean" "Configure" "Build" "All") -comp_functions=("comp_clean" "comp_configure" "comp_build" "all") +function comp_quit() { + exit 0 +} -runHooks "ON_AFTER_OPTIONS" #you can create your custom options +comp_options=( + "build: Configure and compile" + "clean: Clean build files" + "configure: Run CMake" + "compile: Compile only" + "all: clean, configure and compile" + "quit: Close this menu") +comp_functions=( + "comp_build" + "comp_clean" + "comp_configure" + "comp_compile" + "comp_all" + "comp_quit") -# push exit after custom options -comp_options+=('Exit') -comp_functions+=('exit 0') +PS3='[ Please enter your choice ]: ' -# run option directly if specified in argument -[ ! -z $1 ] && run_option $1 && exit 0 +runHooks "ON_AFTER_OPTIONS" #you can create your custom options -PS3='[ Please enter your choice ]: ' -select opt in "${comp_options[@]}" -do - case $opt in - 'Exit') - break +function _switch() { + _reply="$1" + _opt="$2" + + case $_reply in + ""|"--help") + echo "Available commands:" + printf '%s\n' "${options[@]}" ;; *) - run_option $REPLY + run_option $_reply $_opt ;; esac +} + + +while true +do + # run option directly if specified in argument + [ ! -z $1 ] && _switch $@ + [ ! -z $1 ] && exit 0 + + select opt in "${comp_options[@]}" + do + echo "==== ACORE COMPILER ====" + _switch $REPLY + break; + done done |