default to port 7070

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

@ -54,7 +54,6 @@ then:
## usage
Usage:
phd [options] <root directory>
@ -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

@ -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<String> = 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,
);
}

Loading…
Cancel
Save