add ent comment, to add a comment on an issue

This commit is contained in:
Sebastian Kuzminsky 2025-07-07 16:15:01 -06:00
parent 9870d42fdc
commit 8ac4ca4c54

View file

@ -39,6 +39,12 @@ enum Commands {
issue_id: String,
new_state: Option<State>,
},
/// Create a new comment on an issue.
Comment {
issue_id: String,
description: Option<String>,
},
}
fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<()> {
@ -128,6 +134,27 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<(
}
}
}
Commands::Comment {
issue_id,
description,
} => {
let mut issues =
entomologist::issues::Issues::new_from_dir(std::path::Path::new(issues_dir))?;
let Some(issue) = issues.get_mut_issue(issue_id) else {
return Err(anyhow::anyhow!("issue {} not found", issue_id));
};
println!("found issue {}", issue.title());
let mut comment = issue.new_comment()?;
match description {
Some(description) => {
comment.set_description(description)?;
}
None => {
comment.edit_description()?;
}
}
}
}
Ok(())