eclipse-web 0.13.2

Local web dashboard for eclipse
Documentation
//! `eclipse-web`: the local dashboard, on its own.
//!
//! The router, the state and the startup rules live in the library so the gateway can serve
//! the same dashboard with more on it. This binary is the dashboard and nothing else.

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 {
    /// Path to config file (default: $XDG_CONFIG_HOME/eclipse/config.toml)
    #[arg(long, env = "ECLIPSE_CONFIG")]
    config: Option<PathBuf>,
    /// Override web.host (must be a loopback address)
    #[arg(long)]
    host: Option<String>,
    /// Override web.port
    #[arg(long)]
    port: Option<u16>,
    /// Use a profile: its config overlay, its own sessions, its own plugins
    #[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();
    // The banner says which door this install has (`#266`): telling somebody to sign in with the
    // token when a password is set sends them at the wrong secret, and the page will not offer it.
    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
}