Ultima attività 1 month ago

Punto de entrada y enrutador de subcomandos (capitulo 07)

main.rs Raw
1mod cli;
2mod completions;
3mod dashboard;
4mod grep;
5mod logparse;
6mod stats;
7mod sysinfo_mod;
8
9use anyhow::Result;
10use clap::Parser;
11use cli::{Cli, Comandos};
12
13fn main() -> Result<()> {
14 let cli = Cli::parse();
15
16 match &cli.comando {
17 Comandos::Stats { archivo } => stats::ejecutar(archivo),
18 Comandos::Logparse { nivel, quiet, archivo } => {
19 logparse::ejecutar(archivo, nivel, *quiet)
20 }
21 Comandos::Sysinfo { formato } => sysinfo_mod::ejecutar(formato),
22 Comandos::Grep { patron, ignorar_mayusculas, archivo } => {
23 grep::ejecutar(patron, *ignorar_mayusculas, archivo)
24 }
25 Comandos::Dashboard { watch } => dashboard::ejecutar(*watch),
26 Comandos::Completions { shell } => completions::ejecutar(shell),
27 }
28}