Allow choosing port number.
This commit is contained in:
parent
1d1406bb2b
commit
6b2bc43d79
@ -14,14 +14,15 @@ Synopsis: `isidore <command> [options]`
|
|||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
|
|
||||||
- `new [-i] <dir>`: create a new project.
|
- `new [args] <dir>`: create a new project.
|
||||||
- `<dir>`: new project directory.
|
- `<dir>`: new project directory.
|
||||||
- `-i`: interactive mode.
|
- `-i`: interactive mode.
|
||||||
- `build [-v] [-j<n>]`: build the website.
|
- `build [args]`: build the website.
|
||||||
- `-j<n>`: number of jobs to run concurrently. With `0` it compiles all files
|
- `-j<n>`: number of jobs to run concurrently. With `0` it compiles all files
|
||||||
at once.
|
at once.
|
||||||
- `-v`: run with verbose output.
|
- `-v`: run with verbose output.
|
||||||
- `serve`, `server`: run an HTTP server of the output on port 8080.
|
- `serve`, `server [args]`: run an HTTP server of the output (default port 8080).
|
||||||
|
- `-p <port>`: port number to bind server to.
|
||||||
- `clean`: cleans build files.
|
- `clean`: cleans build files.
|
||||||
- `help`: show help information.
|
- `help`: show help information.
|
||||||
- `version`: show Isidore version number.
|
- `version`: show Isidore version number.
|
||||||
|
27
isidore.sh
27
isidore.sh
@ -95,8 +95,8 @@ function print_help()
|
|||||||
Create a new Isidore project
|
Create a new Isidore project
|
||||||
build [-v] [-j<n>]
|
build [-v] [-j<n>]
|
||||||
Build the project rooted in the current directory
|
Build the project rooted in the current directory
|
||||||
serve | server
|
serve | server [-p <port>]
|
||||||
Serve a local HTTP server of the output directory on port 8080
|
Serve a local HTTP server of the output directory
|
||||||
clean
|
clean
|
||||||
Clean the built files
|
Clean the built files
|
||||||
version
|
version
|
||||||
@ -281,7 +281,28 @@ case $1 in
|
|||||||
done
|
done
|
||||||
build_project $VERBOSE $JOBS;;
|
build_project $VERBOSE $JOBS;;
|
||||||
serve|server)
|
serve|server)
|
||||||
php -S localhost:8080 -t $OUTPUT_DIR/;;
|
PORT=8080
|
||||||
|
shift
|
||||||
|
while getopts "p:" opt
|
||||||
|
do
|
||||||
|
case $opt in
|
||||||
|
p)
|
||||||
|
if ! [[ "$OPTARG" =~ ^[0-9]+$ ]]
|
||||||
|
then
|
||||||
|
echo "Invalid port $OPTARG. Please enter a number."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
PORT=$OPTARG;;
|
||||||
|
?)
|
||||||
|
echo "Invalid argument $OPTARG. Use the 'help' subcommand."
|
||||||
|
print_usage
|
||||||
|
exit 1;;
|
||||||
|
:)
|
||||||
|
echo "Option -$OPTARG requires an argument."
|
||||||
|
exit 1;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
php -S localhost:$PORT -t $OUTPUT_DIR/;;
|
||||||
clean)
|
clean)
|
||||||
clean_project;;
|
clean_project;;
|
||||||
help)
|
help)
|
||||||
|
Loading…
Reference in New Issue
Block a user