Compare commits

..

2 Commits

Author SHA1 Message Date
91b8b3b570 Add verbose flag to build. 2022-11-08 16:10:07 +01:00
e5bbf2dc03 Test for too few commands. 2022-11-08 16:02:38 +01:00
2 changed files with 40 additions and 6 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
@ -204,6 +216,13 @@ function build_project()
set_config_vars set_config_vars
if [ $# -lt 1 ]
then
echo "No subcommand was specified. Use the 'help' subcommand."
print_usage
exit 1
fi
case $1 in case $1 in
new) new)
if [ $# -lt 2 ] if [ $# -lt 2 ]
@ -224,15 +243,30 @@ case $1 in
then then
NEW_DIR="$i" NEW_DIR="$i"
else else
echo "Unknown argument for new '$i'. Use the 'help' command." 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)
@ -242,7 +276,7 @@ case $1 in
version) version)
echo "$PROJECT_NAME v$ISIDORE_VERSION";; echo "$PROJECT_NAME v$ISIDORE_VERSION";;
*) *)
echo "Unknown command $1. Use the 'help' command." echo "Unknown command $1. Use the 'help' subcommand."
print_usage print_usage
exit 1;; exit 1;;
esac esac