//! Clap-derive subcommand definition for `maestro tui`. #[derive(Debug, clap::Args)] pub struct TuiArgs { /// Override the local daemon's HTTP base URL. Defaults to /// `[cli].daemon_url`, then the local `[daemon].bind_addr`, then /// `http://127.0.0.1:7070`. #[arg(long, env = "MAESTRO_DAEMON_URL")] pub daemon_url: Option, } #[cfg(test)] mod tests { use super::*; use clap::Parser; #[derive(Debug, Parser)] struct Harness { #[command(subcommand)] cmd: Cmd, } #[derive(Debug, clap::Subcommand)] enum Cmd { Tui(TuiArgs), } #[test] fn parses_with_daemon_url() { let h = Harness::try_parse_from(["maestro", "tui", "--daemon-url", "http://10.0.0.1:7070"]) .unwrap(); let Cmd::Tui(args) = h.cmd; assert_eq!(args.daemon_url.as_deref(), Some("http://10.0.0.1:7070")); } #[test] fn parses_without_daemon_url() { let h = Harness::try_parse_from(["maestro", "tui"]).unwrap(); let Cmd::Tui(args) = h.cmd; assert!(args.daemon_url.is_none()); } }