better interface to looking up issue

This commit is contained in:
Sebastian Kuzminsky 2025-07-07 16:14:19 -06:00
parent b789a3d293
commit 4307ab98a0
2 changed files with 10 additions and 2 deletions

View file

@ -62,7 +62,7 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<(
Commands::Edit { issue_id } => {
let mut issues =
entomologist::issues::Issues::new_from_dir(std::path::Path::new(issues_dir))?;
match issues.issues.get_mut(issue_id) {
match issues.get_mut_issue(issue_id) {
Some(issue) => {
issue.edit_description()?;
}
@ -74,7 +74,7 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<(
Commands::Show { issue_id } => {
let issues =
entomologist::issues::Issues::new_from_dir(std::path::Path::new(issues_dir))?;
match issues.issues.get(issue_id) {
match issues.get_issue(issue_id) {
Some(issue) => {
println!("issue {}", issue_id);
println!("state: {:?}", issue.state);

View file

@ -35,6 +35,14 @@ impl Issues {
self.issues.insert(uuid, issue);
}
pub fn get_issue(&self, issue_id: &str) -> Option<&crate::issue::Issue> {
self.issues.get(issue_id)
}
pub fn get_mut_issue(&mut self, issue_id: &str) -> Option<&mut crate::issue::Issue> {
self.issues.get_mut(issue_id)
}
fn parse_config(&mut self, config_path: &std::path::Path) -> Result<(), ReadIssuesError> {
let config_contents = std::fs::read_to_string(config_path)?;
let config: Config = toml::from_str(&config_contents)?;