From 6cc1cd0ea5769cf087025a3fda78a39577fb606c Mon Sep 17 00:00:00 2001 From: Mohammad Yaaghubi Date: Thu, 10 Aug 2023 21:22:48 +0330 Subject: [PATCH] Change `-c|--clean` to `-f|--fresh` & fixes --- README.md | 5 +++++ base/hello_world.sh | 2 +- base/option_target.sh | 11 +++++++++-- benchmark.sh | 22 +++++++++++++--------- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 561da9f..e33d7a0 100755 --- a/README.md +++ b/README.md @@ -138,6 +138,10 @@ $ bash benchmark.sh ## Commands ```bash +# some options +# use bash benchmark.sh --help +$ bash benchmark.sh -f -rapache -rnginx -t ... + # run composer update for frameworks $ bash update.sh @@ -157,6 +161,7 @@ To specify frameworks, put them with `-t ...` after each command: ```bash # supported for `setup.sh`, `benchmark.sh`, `update.sh`, `clean.sh`, and `clear-cache.sh` +# not required to put / after the name, just use the tab in your terminal # bash benchmarks.sh --help -h $ bash benchmark.sh -t laravel-10.0/ slim-4.11/ ... ... diff --git a/base/hello_world.sh b/base/hello_world.sh index 512001c..e312866 100755 --- a/base/hello_world.sh +++ b/base/hello_world.sh @@ -54,7 +54,7 @@ do # continue # fi - if [ "$param_clean" = true ]; then + if [ "$param_fresh" = true ]; then bash clean.sh bash setup.sh -t "$fw" fi diff --git a/base/option_target.sh b/base/option_target.sh index a29ec72..0b54f9e 100644 --- a/base/option_target.sh +++ b/base/option_target.sh @@ -9,7 +9,7 @@ function showHelp() { cat << HEREDOC - Usage: bash check.sh [-t pure-php/ slim-*] + Usage: bash check.sh [-t pure-php slim-*] Optional Arguments: -h, --help Show this help message and exit @@ -30,6 +30,7 @@ IFS=';' params=(`php ./libs/strreplace.php " -" ";-" " ${paramsin}"`) IFS=$oldIFS +init_benchmark=true for option in "${params[@]}" do case "$option" in @@ -41,13 +42,19 @@ do fi ;; -h|--help) + init_benchmark=false showHelp; ;; ""|" ") ;; *) + init_benchmark=false echo "\"${option}\" not available" exit 1 ;; esac -done \ No newline at end of file +done + +if [ "$init_benchmark" = false ]; then + exit 1 +fi \ No newline at end of file diff --git a/benchmark.sh b/benchmark.sh index 533eb19..2cb281e 100644 --- a/benchmark.sh +++ b/benchmark.sh @@ -21,10 +21,10 @@ function showHelp() { cat << HEREDOC - Usage: bash benchmark.sh [-c] [-rapache] [-t pure-php slim] + Usage: bash benchmark.sh [-f] [-rapache] [-t pure-php slim] Optional Arguments: - -c, --clean Clean all frameworks and install the target framework -fresh install- before benchmark. + -f, --fresh Clean all frameworks and install the target framework -fresh install- before benchmark. -h, --help Show this help message and exit -rapache, --restart-apache Restart apache "sudo systemctl restart apache2" before each benchmark. -rnginx, --restart-nginx Restart apache "sudo systemctl restart nginx" before each benchmark. @@ -35,7 +35,7 @@ HEREDOC } export param_targets="$frameworks_list" -export param_clean=false +export param_fresh=false export param_restart_apache=false export param_restart_nginx=false @@ -48,11 +48,12 @@ IFS=';' params=(`php ./libs/strreplace.php " -" ";-" " ${paramsin}"`) IFS=$oldIFS +init_benchmark=true for option in "${params[@]}" do case "$option" in - -c|--clean) - param_clean=true + -f|--fresh) + param_fresh=true ;; -rapache|--restart-apache) param_restart_apache=true @@ -68,18 +69,21 @@ do fi ;; -h|--help) + init_benchmark=false showHelp; ;; ""|" ") ;; *) + init_benchmark=false echo "\"${option}\" not available" exit 1 ;; esac done -sh ./base/hello_world.sh - -echo '' -php ./libs/show_results_table.php \ No newline at end of file +if [ "$init_benchmark" = true ]; then + sh ./base/hello_world.sh + echo '' + php ./libs/show_results_table.php +fi \ No newline at end of file