use std::path::PathBuf; use structopt::StructOpt; use anyhow::Error; #[derive(Debug, StructOpt)] #[structopt(name = "distrox", about = "Distrox - The distributed social network")] pub struct CLI { #[structopt(short, long)] debug: bool, #[structopt(short, long)] trace: bool, #[structopt(short, long)] port: Option, #[structopt(parse(from_os_str))] configfile: Option, #[structopt(subcommand)] cmd: Option } impl CLI { pub fn cmd(&self) -> Option<&Command> { self.cmd.as_ref() } pub fn port(&self) -> Option { self.port.as_ref().map(|p| *p) } } #[derive(Debug, PartialEq, StructOpt)] #[structopt(about = "Start the server part (running in foreground")] pub enum Command { Server, } pub fn cli() -> Result { Ok(CLI::from_args()) }