use std::net::SocketAddr; use clap::{Parser, Subcommand}; use crate::{api, state::SharedState}; pub async fn execute() -> anyhow::Result<()> { let state = SharedState::new().await?; let cli = Command::parse(); if let Some(Commands::Serve { host }) = cli.command { tracing::info!("Starting service"); notmad::Mad::builder() .add(api::Api::new(&state, host)) .run() .await?; } Ok(()) } #[derive(Parser)] #[command(author, version, about, long_about = None, subcommand_required = true)] struct Command { #[command(subcommand)] command: Option, } #[derive(Subcommand)] enum Commands { Serve { #[arg(env = "SERVICE_HOST", long, default_value = "127.0.0.1:3000")] host: SocketAddr, }, }