mod cli;
mod command;
mod filter;
use anyhow::Result;
use clap::CommandFactory;
use clap::Parser;
use cli::Action;
use cli::Cli;
use iceoryx2_log::{set_log_level_from_env_or, LogLevel};
#[cfg(not(debug_assertions))]
use human_panic::setup_panic;
#[cfg(debug_assertions)]
extern crate better_panic;
fn main() -> Result<()> {
#[cfg(not(debug_assertions))]
{
setup_panic!();
}
#[cfg(debug_assertions)]
{
better_panic::Settings::debug()
.most_recent_first(false)
.lineno_suffix(true)
.verbosity(better_panic::Verbosity::Full)
.install();
}
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(())
}