Add verbose flag to build.

This commit is contained in:
Nicolás A. Ortega Froysa 2022-11-08 16:08:56 +01:00
parent e5bbf2dc03
commit 91b8b3b570
2 changed files with 32 additions and 4 deletions

View File

@ -16,7 +16,7 @@ Commands:
- `new [-i] <dir>`: create a new project directory `<dir>`. Use `-i` for - `new [-i] <dir>`: create a new project directory `<dir>`. Use `-i` for
interactive mode. 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. - `serve`, `server`: run an HTTP server of the output on port 8080.
- `clean`: cleans build files. - `clean`: cleans build files.
- `help`: show help information. - `help`: show help information.

View File

@ -169,6 +169,9 @@ function clean_project()
## ##
# Build the project. # Build the project.
#
# Params:
# $1 - Verbose flag
## ##
function build_project() function build_project()
{ {
@ -191,12 +194,21 @@ function build_project()
cat $CFG_HEADER_FILE $i > $TMP_DIR/$i cat $CFG_HEADER_FILE $i > $TMP_DIR/$i
: ${i:${#SOURCE_DIR}} : ${i:${#SOURCE_DIR}}
OUT_FILE="$OUTPUT_DIR/${_: :-4}" OUT_FILE="$OUTPUT_DIR/${_: :-4}"
if [ $1 == 1 ]
then
echo "Building $OUT_FILE ..."
fi
php $TMP_DIR/$i > $OUT_FILE php $TMP_DIR/$i > $OUT_FILE
done done
for i in $(find $SOURCE_DIR -type f -not -name '*.php') for i in $(find $SOURCE_DIR -type f -not -name '*.php')
do 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 done
rm -r $TMP_DIR rm -r $TMP_DIR
@ -207,6 +219,7 @@ set_config_vars
if [ $# -lt 1 ] if [ $# -lt 1 ]
then then
echo "No subcommand was specified. Use the 'help' subcommand." echo "No subcommand was specified. Use the 'help' subcommand."
print_usage
exit 1 exit 1
fi fi
@ -233,12 +246,27 @@ case $1 in
echo "Unknown argument for new '$i'. Use the 'help' subcommand." echo "Unknown argument for new '$i'. Use the 'help' subcommand."
print_usage print_usage
exit 1 exit 1
fi fi;;
esac esac
done done
new_project $NEW_DIR $INTERACTIVE;; new_project $NEW_DIR $INTERACTIVE;;
build) 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) serve|server)
php -S localhost:8080 -t $OUTPUT_DIR/;; php -S localhost:8080 -t $OUTPUT_DIR/;;
clean) clean)