From 91b8b3b570c6b9d076189bd035994604506ae0b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20A=2E=20Ortega=20Froysa?= Date: Tue, 8 Nov 2022 16:08:56 +0100 Subject: [PATCH] Add verbose flag to build. --- README.md | 2 +- isidore.sh | 34 +++++++++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dff977e..8c5d308 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Commands: - `new [-i] `: create a new project directory ``. Use `-i` for interactive mode. -- `build`: build the website (default). +- `build [-v]`: build the website (default). Use `-v` for verbose. - `serve`, `server`: run an HTTP server of the output on port 8080. - `clean`: cleans build files. - `help`: show help information. diff --git a/isidore.sh b/isidore.sh index 0bccb5d..67aeb35 100755 --- a/isidore.sh +++ b/isidore.sh @@ -169,6 +169,9 @@ function clean_project() ## # Build the project. +# +# Params: +# $1 - Verbose flag ## function build_project() { @@ -191,12 +194,21 @@ function build_project() cat $CFG_HEADER_FILE $i > $TMP_DIR/$i : ${i:${#SOURCE_DIR}} OUT_FILE="$OUTPUT_DIR/${_: :-4}" + if [ $1 == 1 ] + then + echo "Building $OUT_FILE ..." + fi php $TMP_DIR/$i > $OUT_FILE done for i in $(find $SOURCE_DIR -type f -not -name '*.php') do - cp $i $OUTPUT_DIR/${i:${#SOURCE_DIR}} + OUT_FILE="$OUTPUT_DIR/${i:${#SOURCE_DIR}}" + if [ $1 == 1 ] + then + echo "Copying $OUT_FILE ..." + fi + cp $i $OUT_FILE done rm -r $TMP_DIR @@ -207,6 +219,7 @@ set_config_vars if [ $# -lt 1 ] then echo "No subcommand was specified. Use the 'help' subcommand." + print_usage exit 1 fi @@ -233,12 +246,27 @@ case $1 in echo "Unknown argument for new '$i'. Use the 'help' subcommand." print_usage exit 1 - fi + fi;; esac done new_project $NEW_DIR $INTERACTIVE;; build) - build_project;; + VERBOSE=0 + if [ $# -gt 1 ] + then + for i in ${@:2} + do + case $i in + -v) + VERBOSE=1;; + *) + echo "Unknown argument for build '$i'. Use the 'help' subcommand." + print_usage + exit 1;; + esac + done + fi + build_project $VERBOSE;; serve|server) php -S localhost:8080 -t $OUTPUT_DIR/;; clean)