Skip to main content

max / alloy_tui

1.8 KB · 67 lines History Blame Raw
1 //! `alloy` — the Alloy Console.
2 //!
3 //! One binary, one subcommand per system surface, all sharing the `alloy_tui`
4 //! design system and the shell in [`shell`]. See docs/CONSOLE.md for the
5 //! subcommand roster and the roadmap; `net` is the first of them.
6 //!
7 //! <!-- wiki: alloy-console -->
8
9 mod audio;
10 mod cli;
11 mod mesh;
12 mod net;
13 mod shell;
14 mod theme;
15
16 use anyhow::Result;
17 use clap::{Parser, Subcommand};
18
19 use crate::cli::CommandLog;
20
21 #[derive(Parser)]
22 #[command(name = "alloy", about = "Alloy Console", version)]
23 struct Cli {
24 /// Theme id to render in (default: Akari, matched to the terminal background)
25 #[arg(long, global = true)]
26 theme: Option<String>,
27
28 #[command(subcommand)]
29 command: Command,
30 }
31
32 #[derive(Subcommand)]
33 enum Command {
34 /// Network interfaces and connections
35 Net,
36 /// Audio outputs and inputs
37 Audio,
38 // `tail` stays as an alias: docs/CONSOLE.md named the verb that way, and
39 // the muscle memory is worth more than the tidiness of a single name.
40 // Deliberately a plain comment, not a doc comment — clap turns those into
41 // `--help` text, and this is a note to maintainers, not to users.
42 /// Mesh network peers and exit node
43 #[command(alias = "tail")]
44 Mesh,
45 }
46
47 fn main() -> Result<()> {
48 let cli = Cli::parse();
49 let theme = theme::load(cli.theme.as_deref())?;
50 let mut log = CommandLog::new();
51
52 match cli.command {
53 Command::Net => {
54 let mut view = net::NetView::new(&mut log);
55 shell::run(&theme, &mut view, &mut log)
56 }
57 Command::Audio => {
58 let mut view = audio::AudioView::new(&mut log);
59 shell::run(&theme, &mut view, &mut log)
60 }
61 Command::Mesh => {
62 let mut view = mesh::MeshView::new(&mut log);
63 shell::run(&theme, &mut view, &mut log)
64 }
65 }
66 }
67