diff options
| author | Ellie Huxtable <e@elm.sh> | 2021-04-09 12:40:21 +0100 |
|---|---|---|
| committer | Ellie Huxtable <e@elm.sh> | 2021-04-09 12:40:21 +0100 |
| commit | 9f16f76bd8d15824e27e971245ea93271fe76b29 (patch) | |
| tree | 6687ec0f743edb682dbb9f04f688fd059f404174 /src/command/server.rs | |
| parent | Bump rusqlite from 0.24.2 to 0.25.0 (#30) (diff) | |
| download | atuin-9f16f76bd8d15824e27e971245ea93271fe76b29.zip | |
Update config
Diffstat (limited to '')
| -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(()) } } |
