From 9f16f76bd8d15824e27e971245ea93271fe76b29 Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Fri, 9 Apr 2021 12:40:21 +0100 Subject: Update config --- src/command/server.rs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src/command') diff --git a/src/command/server.rs b/src/command/server.rs index 9d9bcb3a..5156f409 100644 --- a/src/command/server.rs +++ b/src/command/server.rs @@ -6,13 +6,32 @@ use crate::settings::Settings; #[derive(StructOpt)] pub enum Cmd { - Start { host: Vec }, + #[structopt( + about="starts the server", + aliases=&["s", "st", "sta", "star"], + )] + Start { + #[structopt(about = "specify the host address to bind", long, short)] + host: Option, + + #[structopt(about = "specify the port to bind", long, short)] + port: Option, + }, } -#[allow(clippy::unused_self)] // I'll use it later impl Cmd { pub fn run(&self, settings: &Settings) -> Result<()> { - server::launch(settings); + match self { + Self::Start { host, port } => { + let host = host.as_ref().map_or( + settings.remote.host.clone(), + std::string::ToString::to_string, + ); + let port = port.map_or(settings.remote.port, |p| p); + + server::launch(settings, host, port); + } + } Ok(()) } } -- cgit v1.3.1