default to port 7070

pull/1/head
dvkt 5 years ago
parent 58efacaa08
commit 5dce199301

@ -54,7 +54,6 @@ then:
## usage ## usage
Usage: Usage:
phd [options] <root directory> phd [options] <root directory>
@ -71,9 +70,9 @@ then:
Examples: Examples:
phd ./path/to/gopher/root # Serve directory over port 70. phd ./path/to/gopher/root # Serve directory over port 7070.
phd -p 7070 docs # Serve 'docs' directory on port 7070 phd -p 70 docs # Serve 'docs' directory on port 70
phd -h localhost # Serve current dir using hostname "localhost". phd -h gopher.com # Serve current dir on 7070 using hostname "gopher.com".
## installation ## installation

@ -1,12 +1,15 @@
use phd; use phd;
use std::process; use std::process;
const DEFAULT_HOST: &str = "127.0.0.1";
const DEFAULT_PORT: u16 = 7070;
fn main() { fn main() {
let args: Vec<String> = std::env::args().collect(); let args: Vec<String> = std::env::args().collect();
let mut root = "."; let mut root = ".";
let mut iter = args.iter(); let mut iter = args.iter();
let mut host = "localhost"; let mut host = DEFAULT_HOST;
let mut port = 70; let mut port = DEFAULT_PORT;
while let Some(arg) = iter.next() { while let Some(arg) = iter.next() {
match arg.as_ref() { match arg.as_ref() {
"--version" | "-v" | "-version" => return print_version(), "--version" | "-v" | "-version" => return print_version(),
@ -58,13 +61,15 @@ fn print_help() {
Options: Options:
-p, --port Port to bind to. -p, --port Port to bind to. [Default: {port}]
-h, --host Hostname to use when generating links. -h, --host Hostname when generating links. [Default: {host}]
Other flags: Other flags:
-h, --help Print this screen. -h, --help Print this screen.
-v, --version Print phd version." -v, --version Print phd version.",
host = DEFAULT_HOST,
port = DEFAULT_PORT,
); );
} }

Loading…
Cancel
Save