From e7ab89f050921bd6614e8fd9e44c8388f514af55 Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Fri, 26 Apr 2024 10:13:47 +0200 Subject: [PATCH] better error display --- src/main.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 346544a..a0477a9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,24 +9,37 @@ use autocrate::{ release::release, serverapi::ApiCollection, }; +use libpt::log::error; #[tokio::main] async fn main() -> Result<()> { let cli = Cli::cli_parse(); let cfg = Config::load(&cli)?; - match cli.command { + let status: Option = match cli.command { Commands::Changelog { .. } => { - println!("{}", Changelog::build(&cfg)?); + let chlog = Changelog::build(&cfg); + if chlog.is_ok() { + println!("{}", chlog.unwrap()); + None + } else { + Some(chlog.unwrap_err()) + } } Commands::Release { .. } => { // TODO: check if repo is dirty and create a commit with a given option let mut apis = ApiCollection::build(&cfg).await?; - release(&cfg, &mut apis).await?; + match release(&cfg, &mut apis).await { + Ok(_) => None, + Err(err) => Some(err) + } } Commands::Publish { .. } => { // TODO: check if repo is dirty and create a commit with a given option - publish(&cfg).await?; + match publish(&cfg).await { + Ok(_) => None, + Err(err) => Some(err) + } } Commands::Version {} => { // TODO: version bump @@ -39,5 +52,8 @@ async fn main() -> Result<()> { todo!() } }; + if let Some(err) = status { + error!("{err}"); + } Ok(()) }