//! `alloy` — the Alloy Console. //! //! One binary, one subcommand per system surface, all sharing the `alloy_tui` //! design system and the shell in [`shell`]. See docs/CONSOLE.md for the //! subcommand roster and the roadmap; `net` is the first of them. //! //! mod audio; mod cli; mod mesh; mod net; mod shell; mod theme; use anyhow::Result; use clap::{Parser, Subcommand}; use crate::cli::CommandLog; #[derive(Parser)] #[command(name = "alloy", about = "Alloy Console", version)] struct Cli { /// Theme id to render in (default: Akari, matched to the terminal background) #[arg(long, global = true)] theme: Option, #[command(subcommand)] command: Command, } #[derive(Subcommand)] enum Command { /// Network interfaces and connections Net, /// Audio outputs and inputs Audio, // `tail` stays as an alias: docs/CONSOLE.md named the verb that way, and // the muscle memory is worth more than the tidiness of a single name. // Deliberately a plain comment, not a doc comment — clap turns those into // `--help` text, and this is a note to maintainers, not to users. /// Mesh network peers and exit node #[command(alias = "tail")] Mesh, } fn main() -> Result<()> { let cli = Cli::parse(); let theme = theme::load(cli.theme.as_deref())?; let mut log = CommandLog::new(); match cli.command { Command::Net => { let mut view = net::NetView::new(&mut log); shell::run(&theme, &mut view, &mut log) } Command::Audio => { let mut view = audio::AudioView::new(&mut log); shell::run(&theme, &mut view, &mut log) } Command::Mesh => { let mut view = mesh::MeshView::new(&mut log); shell::run(&theme, &mut view, &mut log) } } }