Allow choosing port number.
This commit is contained in:
		@@ -14,14 +14,15 @@ Synopsis: `isidore <command> [options]`
 | 
			
		||||
 | 
			
		||||
Commands:
 | 
			
		||||
 | 
			
		||||
- `new [-i] <dir>`: create a new project.
 | 
			
		||||
- `new [args] <dir>`: create a new project.
 | 
			
		||||
  - `<dir>`: new project directory.
 | 
			
		||||
  - `-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
 | 
			
		||||
    at once.
 | 
			
		||||
  - `-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.
 | 
			
		||||
- `help`: show help information.
 | 
			
		||||
- `version`: show Isidore version number.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										27
									
								
								isidore.sh
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								isidore.sh
									
									
									
									
									
								
							@@ -95,8 +95,8 @@ function print_help()
 | 
			
		||||
    Create a new Isidore project
 | 
			
		||||
  build [-v] [-j<n>]
 | 
			
		||||
    Build the project rooted in the current directory
 | 
			
		||||
  serve | server
 | 
			
		||||
    Serve a local HTTP server of the output directory on port 8080
 | 
			
		||||
  serve | server [-p <port>]
 | 
			
		||||
    Serve a local HTTP server of the output directory
 | 
			
		||||
  clean
 | 
			
		||||
    Clean the built files
 | 
			
		||||
  version
 | 
			
		||||
@@ -281,7 +281,28 @@ case $1 in
 | 
			
		||||
		done
 | 
			
		||||
		build_project $VERBOSE $JOBS;;
 | 
			
		||||
	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_project;;
 | 
			
		||||
	help)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user