diff --git a/README.md b/README.md index 385f145..e463386 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,6 @@ then: ## usage - Usage: phd [options] @@ -71,9 +70,9 @@ then: Examples: - phd ./path/to/gopher/root # Serve directory over port 70. - phd -p 7070 docs # Serve 'docs' directory on port 7070 - phd -h localhost # Serve current dir using hostname "localhost". + phd ./path/to/gopher/root # Serve directory over port 7070. + phd -p 70 docs # Serve 'docs' directory on port 70 + phd -h gopher.com # Serve current dir on 7070 using hostname "gopher.com". ## installation diff --git a/src/main.rs b/src/main.rs index b0763bd..3abd1da 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,15 @@ use phd; use std::process; +const DEFAULT_HOST: &str = "127.0.0.1"; +const DEFAULT_PORT: u16 = 7070; + fn main() { let args: Vec = std::env::args().collect(); let mut root = "."; let mut iter = args.iter(); - let mut host = "localhost"; - let mut port = 70; + let mut host = DEFAULT_HOST; + let mut port = DEFAULT_PORT; while let Some(arg) = iter.next() { match arg.as_ref() { "--version" | "-v" | "-version" => return print_version(), @@ -58,13 +61,15 @@ fn print_help() { Options: - -p, --port Port to bind to. - -h, --host Hostname to use when generating links. + -p, --port Port to bind to. [Default: {port}] + -h, --host Hostname when generating links. [Default: {host}] Other flags: -h, --help Print this screen. - -v, --version Print phd version." + -v, --version Print phd version.", + host = DEFAULT_HOST, + port = DEFAULT_PORT, ); }