1pub mod commands;
2pub mod handlers;
3pub mod interactive;
4pub mod help_examples;
5use clap::Parser;
11use commands::Cli;
12use handlers::handle_command;
13
14pub async fn run() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
16 let args = Cli::parse();
17
18 init_logging()?;
20
21 if let Err(_e) = handle_command(args.command).await {
23 std::process::exit(1);
25 }
26
27 Ok(())
28}
29
30fn init_logging() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
32 use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
33
34 if std::env::var("RUST_LOG").is_err() {
36 std::env::set_var("RUST_LOG", "info");
37 }
38
39 let _result = tracing_subscriber::registry()
41 .with(tracing_subscriber::EnvFilter::from_default_env())
42 .with(tracing_subscriber::fmt::layer())
43 .try_init();
44
45 Ok(())
46}
47
48pub fn handle_error(error: &dyn std::error::Error) {
50 eprintln!("Fatal error: {}", error);
51 tracing::error!("Application error: {}", error);
52}