31 lines
743 B
Rust
31 lines
743 B
Rust
use std::env;
|
|
use clap::Parser;
|
|
|
|
fn current_dir_as_string() -> String {
|
|
env::current_dir()
|
|
.unwrap()
|
|
.into_os_string()
|
|
.into_string()
|
|
.unwrap()
|
|
}
|
|
|
|
#[derive(Parser, Debug)]
|
|
#[command(version, about, long_about = None)]
|
|
pub struct Args {
|
|
/// Port for the web server to listen on.
|
|
#[arg(short, long)]
|
|
pub port: Option<u16>,
|
|
|
|
/// Interface to print URLs for. Default is all interfaces.
|
|
#[arg(short, long, default_value_t = String::from("all"))]
|
|
pub interface: String,
|
|
|
|
/// Directory to serve. Default is your current working directory.
|
|
#[arg(short, long, default_value_t = current_dir_as_string())]
|
|
pub directory: String,
|
|
}
|
|
|
|
pub fn parse_args() -> Args {
|
|
Args::parse()
|
|
}
|