You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
phd/src/main.rs

51 lines
1.0 KiB
Rust

5 years ago
use phd;
5 years ago
use std::process;
5 years ago
fn main() {
5 years ago
let args: Vec<String> = std::env::args().collect();
if args.len() < 2 {
print_usage();
return;
}
let dir = args.get(1).unwrap();
if dir == "--version" || dir == "-v" || dir == "-version" {
print_version();
return;
}
if dir == "--help" || dir == "-h" || dir == "-help" {
print_usage();
return;
}
if !dir.is_empty() && dir.starts_with('-') {
eprintln!("unknown flag: {}", dir);
process::exit(1);
}
5 years ago
println!("-> Listening on localhost:7070");
5 years ago
if let Err(e) = phd::start_server("localhost:7070") {
5 years ago
eprintln!("{}", e);
}
}
5 years ago
fn print_usage() {
println!(
"Usage:
phd [options] <root>
Options:
-p, --port Port to bind to.
-H, --host Hostname to use when generating links.
-h, --help Print this screen.
-v, --version Print phd version."
);
}
fn print_version() {
println!("phd v{}", env!("CARGO_PKG_VERSION"));
}