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, /// 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() }