mod auth;
mod cli;
mod command_spec;
mod config;
mod consts;
mod contacts;
mod dispatch;
mod error;
mod fetch;
mod groups;
mod http;
mod moments;
mod output;
mod payload;
mod plan_audit;
mod prelude;
mod progress;
mod routes;
mod runtime;
mod snapshot;
#[tokio::main]
async fn main() -> std::process::ExitCode {
dispatch::install_diagnostics();
let matches = cli::build_cli().get_matches();
let error_format = error::error_format_from_matches(&matches);
match run(matches).await {
Ok(()) => std::process::ExitCode::SUCCESS,
Err(report) => {
match error_format {
error::ErrorFormat::Human => eprintln!("Error: {report:?}"),
error::ErrorFormat::Json => eprintln!("{}", error::error_envelope(&report)),
}
std::process::ExitCode::from(error::classify_report(&report).exit_code())
}
}
}
async fn run(matches: clap::ArgMatches) -> miette::Result<()> {
let runtime = runtime::Runtime::from_matches(&matches)?;
dispatch::run(matches, runtime).await
}