use clap::Parser;
use eclipse_web::app::router;
use eclipse_web::startup::{self, Options};
use std::path::PathBuf;
#[derive(Parser)]
#[command(
name = "eclipse-web",
version,
about = "Local web dashboard for eclipse"
)]
struct Args {
#[arg(long, env = "ECLIPSE_CONFIG")]
config: Option<PathBuf>,
#[arg(long)]
host: Option<String>,
#[arg(long)]
port: Option<u16>,
#[arg(long, env = "ECLIPSE_PROFILE")]
profile: Option<String>,
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let args = Args::parse();
let opts = Options {
config: args.config,
host: args.host,
port: args.port,
profile: args.profile,
};
let prepared = startup::prepare(&opts).await?;
let state = prepared.state.clone();
let door = match state.auth_mode() {
"password" => "sign in with the user and password from .env",
_ => "sign in with web.auth_token from your config",
};
startup::serve(
prepared,
router(state),
&format!("eclipse dashboard ({door})"),
)
.await
}