#[macro_use]
extern crate log;
extern crate serde_crate as serde;
use std::process::ExitCode;
use bp_util::{Args, BpCommand, Config, DescrStdOpts, Exec, LogLevel, RuntimeError};
use clap::Parser;
fn main() -> ExitCode {
if let Err(err) = run() {
eprintln!("Error: {err}");
ExitCode::FAILURE
} else {
ExitCode::SUCCESS
}
}
fn run() -> Result<(), RuntimeError> {
let mut args = Args::<BpCommand, DescrStdOpts>::parse();
args.process();
LogLevel::from_verbosity_flag_count(args.verbose).apply();
trace!("Command-line arguments: {:#?}", &args);
eprintln!("BP: command-line wallet for bitcoin protocol");
eprintln!(" by LNP/BP Standards Association\n");
let conf = Config::load(&args.conf_path("bp"));
debug!("Executing command: {}", args.command);
args.exec(conf, "bp")
}