simplify ent new

This commit is contained in:
Sebastian Kuzminsky 2025-07-09 22:12:58 -06:00
parent acf539c683
commit e09e4b9cb7

View file

@ -132,18 +132,24 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<(
} }
} }
Commands::New { Commands::New { description } => {
description: Some(description),
} => {
let mut issue = entomologist::issue::Issue::new(issues_dir)?; let mut issue = entomologist::issue::Issue::new(issues_dir)?;
issue.set_description(description)?; let r = match description {
println!("created new issue '{}'", issue.title()); Some(description) => issue.set_description(description),
} None => issue.edit_description(),
};
Commands::New { description: None } => { match r {
let mut issue = entomologist::issue::Issue::new(issues_dir)?; Err(entomologist::issue::IssueError::EmptyDescription) => {
issue.edit_description()?; println!("no new issue created");
println!("created new issue '{}'", issue.title()); return Ok(());
}
Err(e) => {
return Err(e.into());
}
Ok(()) => {
println!("created new issue '{}'", issue.title());
}
}
} }
Commands::Edit { issue_id } => { Commands::Edit { issue_id } => {