| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 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 |
|
| 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 |
|
| 35 |
Net, |
| 36 |
|
| 37 |
Audio, |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 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 |
|