diff options
Diffstat (limited to 'src/command/server.rs')
-rw-r--r-- | src/command/server.rs | 25 |
1 files changed, 22 insertions, 3 deletions
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<String> }, + #[structopt( + about="starts the server", + aliases=&["s", "st", "sta", "star"], + )] + Start { + #[structopt(about = "specify the host address to bind", long, short)] + host: Option<String>, + + #[structopt(about = "specify the port to bind", long, short)] + port: Option<u16>, + }, } -#[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(()) } } |