personal fork of atuin without AI stuff, sync stuff, script management stuff
1use tracing_subscriber::{fmt, prelude::*, EnvFilter};
2
3use clap::Parser;
4use eyre::{Context, Result};
5
6use atuin_server::{launch, settings::Settings};
7
8#[derive(Parser)]
9#[clap(infer_subcommands = true)]
10pub enum Cmd {
11 /// Start the server
12 Start {
13 /// The host address to bind
14 #[clap(long)]
15 host: Option<String>,
16
17 /// The port to bind
18 #[clap(long, short)]
19 port: Option<u16>,
20 },
21}
22
23impl Cmd {
24 pub async fn run(self) -> Result<()> {
25 tracing_subscriber::registry()
26 .with(fmt::layer())
27 .with(EnvFilter::from_default_env())
28 .init();
29
30 let settings = Settings::new().wrap_err("could not load server settings")?;
31
32 match self {
33 Self::Start { host, port } => {
34 let host = host
35 .as_ref()
36 .map_or(settings.host.clone(), std::string::ToString::to_string);
37 let port = port.map_or(settings.port, |p| p);
38
39 launch(settings, host, port).await
40 }
41 }
42 }
43}