mod cli;
mod command;
mod filter;
use anyhow::Result;
use clap::CommandFactory;
use clap::Parser;
use cli::Action;
use cli::Cli;
use iceoryx2_cli::install_panic_handlers;
use iceoryx2_log::{LogLevel, set_log_level_from_env_or};
fn main() -> Result<()> {
install_panic_handlers!();
set_log_level_from_env_or(LogLevel::Warn);
let cli = Cli::parse();
if let Some(action) = cli.action {
match action {
Action::List(options) => {
if let Err(e) = command::list(options.filter, cli.format) {
eprintln!("Failed to list nodes: {e}");
}
}
Action::Details(options) => {
if let Err(e) = command::details(options.node, options.filter, cli.format) {
eprintln!("Failed to retrieve node details: {e}");
}
}
}
} else {
Cli::command().print_help().expect("Failed to print help");
}
Ok(())
}