From 8ac4ca4c543ccddc15aef154601f753df5f51c42 Mon Sep 17 00:00:00 2001 From: Sebastian Kuzminsky Date: Mon, 7 Jul 2025 16:15:01 -0600 Subject: [PATCH] add `ent comment`, to add a comment on an issue --- src/bin/ent/main.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/bin/ent/main.rs b/src/bin/ent/main.rs index 4a86883..63fba60 100644 --- a/src/bin/ent/main.rs +++ b/src/bin/ent/main.rs @@ -39,6 +39,12 @@ enum Commands { issue_id: String, new_state: Option, }, + + /// Create a new comment on an issue. + Comment { + issue_id: String, + description: Option, + }, } 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(())