use clap::arg;
use std::path::PathBuf;
use super::config;
#[derive(Debug, clap::Args, Clone, Default)]
#[group(skip)]
#[allow(clippy::struct_excessive_bools)]
pub struct Args {
#[clap(flatten)]
pub locator: config::locator::Args,
#[arg(long, short = 'f')]
pub filter_logs: Vec<String>,
#[arg(long, short = 'q')]
pub quiet: bool,
#[arg(long, short = 'v')]
pub verbose: bool,
#[arg(long, alias = "vv")]
pub very_verbose: bool,
#[arg(long)]
pub list: bool,
}
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("reading file {filepath}: {error}")]
CannotReadLedgerFile {
filepath: PathBuf,
error: soroban_ledger_snapshot::Error,
},
#[error("committing file {filepath}: {error}")]
CannotCommitLedgerFile {
filepath: PathBuf,
error: soroban_ledger_snapshot::Error,
},
}
impl Args {
pub fn log_level(&self) -> Option<tracing::Level> {
if self.quiet {
None
} else if self.very_verbose {
Some(tracing::Level::TRACE)
} else if self.verbose {
Some(tracing::Level::DEBUG)
} else {
Some(tracing::Level::INFO)
}
}
}