Issue: refactor to simplify & make better git log messages

This starts cleaning up the Issue API.

* Start separating the public API from the internal API.

* Make `Issue::new()` and `Issue::edit_description()` better behaved,
  simpler, reduce code duplication, and also produce better git log
  messages.

* Update `ent` to call the changed `new()` function.

* Add some comments documenting the Issue API.

* `ent new` and `ent edit` now use the editor specified by the EDITOR
  environment variable, if any.  Defaults to `vi` if unspecified.
This commit is contained in:
Sebastian Kuzminsky 2025-07-11 10:06:17 -06:00
parent 7b6efdf925
commit 1477322f81
2 changed files with 103 additions and 57 deletions

View file

@ -216,12 +216,7 @@ fn handle_command(
Commands::New { description } => {
let issues_database =
make_issues_database(issues_database_source, IssuesDatabaseAccess::ReadWrite)?;
let mut issue = entomologist::issue::Issue::new(&issues_database.dir)?;
let r = match description {
Some(description) => issue.set_description(description),
None => issue.edit_description(),
};
match r {
match entomologist::issue::Issue::new(&issues_database.dir, description) {
Err(entomologist::issue::IssueError::EmptyDescription) => {
println!("no new issue created");
return Ok(());
@ -229,7 +224,7 @@ fn handle_command(
Err(e) => {
return Err(e.into());
}
Ok(()) => {
Ok(issue) => {
println!("created new issue '{}'", issue.title());
return Ok(());
}