flusso-cli 0.11.0

flusso command-line interface: keep OpenSearch in sync with Postgres from declarative config.
//! `flusso design` — open the visual schema designer.
//!
//! Serves a local web UI that introspects the configured source *through the
//! source abstraction*, edits `flusso.toml` and the referenced `*.schema.yml`
//! files in place, previews the resulting document/mapping, and validates
//! against the live database. The files stay the source of truth — the UI is a
//! round-tripping view, not a separate model. All the work lives in the
//! `flusso-design` crate; this is the thin CLI entry point.

use std::net::SocketAddr;
use std::path::PathBuf;

use anyhow::Context;
use clap::Args;
use design::DesignOptions;

use crate::DEFAULT_CONFIG;

#[derive(Debug, Args)]
pub(crate) struct DesignArgs {
    /// Path to the configuration file to edit. Created on first save if it does
    /// not exist yet.
    #[arg(short, long, env = "FLUSSO_CONFIG", default_value = DEFAULT_CONFIG)]
    config: PathBuf,

    /// Local address to bind the designer's UI + API to.
    #[arg(long, env = "FLUSSO_DESIGN_ADDRESS", default_value = "127.0.0.1:7700")]
    address: SocketAddr,

    /// Don't open the designer in a browser on start (it opens by default).
    #[arg(long, env = "FLUSSO_DESIGN_NO_OPEN")]
    no_open: bool,
}

pub(crate) async fn execute(args: DesignArgs) -> anyhow::Result<()> {
    // Install the same stderr logging the daemon uses, so the designer's
    // "listening at <url>" line (and any warnings) actually reach the terminal.
    let _tracing = crate::telemetry::init_tracing();
    design::serve(DesignOptions {
        config_path: args.config,
        address: args.address,
        open_browser: !args.no_open,
    })
    .await
    .context("running the designer")
}