atuin/src/command/server.rs
Ellie Huxtable a21737e2b7
Use cargo workspaces (#37)
* Switch to Cargo workspaces

Breaking things into "client", "server" and "common" makes managing the
codebase much easier!

client - anything running on a user's machine for adding history
server - handles storing/syncing history and running a HTTP server
common - request/response API definitions, common utils, etc

* Update dockerfile
2021-04-20 20:53:07 +00:00

36 lines
913 B
Rust

use eyre::Result;
use structopt::StructOpt;
use atuin_server::launch;
use atuin_server::settings::Settings;
#[derive(StructOpt)]
pub enum Cmd {
#[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>,
},
}
impl Cmd {
pub async fn run(&self, settings: &Settings) -> Result<()> {
match self {
Self::Start { host, port } => {
let host = host
.as_ref()
.map_or(settings.host.clone(), std::string::ToString::to_string);
let port = port.map_or(settings.port, |p| p);
launch(settings, host, port).await
}
}
}
}