mod config; mod info; mod motd; mod net; mod roles; mod services; mod storage; mod wifi; use clap::{Parser, Subcommand}; #[derive(Parser)] #[command(name = "sysop", about = "Mountaineer operator interface")] struct Cli { #[command(subcommand)] command: Command, } #[derive(Subcommand)] enum Command { /// Show which tool fills a role and where its config lives Info { /// Role name (omit for the full list) role: Option, }, /// Login tip rotation (on/off/print) Motd { #[command(subcommand)] action: Option, }, /// s6-rc service health view Services { /// One-line summary for the yambar `svc` segment #[arg(long)] summary: bool, }, /// ZFS pool health view Storage { /// One-line summary for the yambar `zfs` segment #[arg(long)] summary: bool, }, /// Connect to a wireless network Wifi, /// Network interface status Net { /// One-line summary for the yambar `net` segment #[arg(long)] summary: bool, }, } #[derive(Subcommand)] enum MotdAction { /// Enable the login tip On, /// Disable the login tip Off, /// Emit the current tip (called by /etc/profile.d/sysop-motd.sh on login) Print, } fn main() -> anyhow::Result<()> { let cli = Cli::parse(); let code = match cli.command { Command::Info { role } => info::run(role)?, Command::Motd { action } => match action { None => motd::status()?, Some(MotdAction::On) => motd::set(true)?, Some(MotdAction::Off) => motd::set(false)?, Some(MotdAction::Print) => motd::print()?, }, Command::Services { summary } => services::run(summary)?, Command::Storage { summary } => storage::run(summary)?, Command::Wifi => wifi::run()?, Command::Net { summary } => net::run(summary)?, }; std::process::exit(code); }