add ent comment, to add a comment on an issue
This commit is contained in:
parent
9870d42fdc
commit
8ac4ca4c54
1 changed files with 27 additions and 0 deletions
|
|
@ -39,6 +39,12 @@ enum Commands {
|
||||||
issue_id: String,
|
issue_id: String,
|
||||||
new_state: Option<State>,
|
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<()> {
|
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(())
|
Ok(())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue