ent: better error reporting

This commit is contained in:
Sebastian Kuzminsky 2025-07-07 16:14:42 -06:00
parent 62c2e113ca
commit 7e63220674

View file

@ -43,6 +43,7 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<(
println!("{} {} ({:?})", uuid, issue.title(), issue.state); println!("{} {} ({:?})", uuid, issue.title(), issue.state);
} }
} }
Commands::New { Commands::New {
description: Some(description), description: Some(description),
} => { } => {
@ -50,11 +51,13 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<(
issue.set_description(description)?; issue.set_description(description)?;
println!("created new issue '{}'", issue.title()); println!("created new issue '{}'", issue.title());
} }
Commands::New { description: None } => { Commands::New { description: None } => {
let mut issue = entomologist::issue::Issue::new(issues_dir)?; let mut issue = entomologist::issue::Issue::new(issues_dir)?;
issue.edit_description()?; issue.edit_description()?;
println!("created new issue '{}'", issue.title()); println!("created new issue '{}'", issue.title());
} }
Commands::Edit { issue_id } => { Commands::Edit { issue_id } => {
let mut issues = let mut issues =
entomologist::issues::Issues::new_from_dir(std::path::Path::new(issues_dir))?; entomologist::issues::Issues::new_from_dir(std::path::Path::new(issues_dir))?;
@ -63,10 +66,11 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<(
issue.edit_description()?; issue.edit_description()?;
} }
None => { None => {
println!("issue {} not found", issue_id); return Err(anyhow::anyhow!("issue {} not found", issue_id));
} }
} }
} }
Commands::Show { issue_id } => { Commands::Show { issue_id } => {
let issues = let issues =
entomologist::issues::Issues::new_from_dir(std::path::Path::new(issues_dir))?; entomologist::issues::Issues::new_from_dir(std::path::Path::new(issues_dir))?;
@ -81,7 +85,7 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<(
println!("{}", issue.description); println!("{}", issue.description);
} }
None => { None => {
println!("issue {} not found", issue_id); return Err(anyhow::anyhow!("issue {} not found", issue_id));
} }
} }
} }