From b789a3d293cb73bdc293c3e3422b5b4ae48fead2 Mon Sep 17 00:00:00 2001 From: Sebastian Kuzminsky Date: Mon, 7 Jul 2025 15:30:46 -0600 Subject: [PATCH 1/3] ent show: show dependencies, if any --- src/bin/ent/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bin/ent/main.rs b/src/bin/ent/main.rs index 187d067..b2eaee2 100644 --- a/src/bin/ent/main.rs +++ b/src/bin/ent/main.rs @@ -77,7 +77,10 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<( match issues.issues.get(issue_id) { Some(issue) => { println!("issue {}", issue_id); - println!("state {:?}", issue.state); + println!("state: {:?}", issue.state); + if let Some(dependencies) = &issue.dependencies { + println!("dependencies: {:?}", dependencies); + } println!(""); println!("{}", issue.description); } From 4307ab98a0bede7ed11ba1da176d6fad53b7ceb5 Mon Sep 17 00:00:00 2001 From: Sebastian Kuzminsky Date: Mon, 7 Jul 2025 16:14:19 -0600 Subject: [PATCH 2/3] better interface to looking up issue --- src/bin/ent/main.rs | 4 ++-- src/issues.rs | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/bin/ent/main.rs b/src/bin/ent/main.rs index b2eaee2..83ebb7f 100644 --- a/src/bin/ent/main.rs +++ b/src/bin/ent/main.rs @@ -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); diff --git a/src/issues.rs b/src/issues.rs index a900ed6..2e40930 100644 --- a/src/issues.rs +++ b/src/issues.rs @@ -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)?; From 035c150f4cc9aa271c2cf2a4b380970bfa8454e0 Mon Sep 17 00:00:00 2001 From: Sebastian Kuzminsky Date: Mon, 7 Jul 2025 16:14:42 -0600 Subject: [PATCH 3/3] ent: better error reporting --- src/bin/ent/main.rs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/bin/ent/main.rs b/src/bin/ent/main.rs index 83ebb7f..9c31c60 100644 --- a/src/bin/ent/main.rs +++ b/src/bin/ent/main.rs @@ -35,7 +35,10 @@ enum Commands { Show { issue_id: String }, /// Modify the state of an issue - State { issue_id: String, new_state: Option }, + State { + issue_id: String, + new_state: Option, + }, } fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<()> { @@ -47,6 +50,7 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<( println!("{} {} ({:?})", uuid, issue.title(), issue.state); } } + Commands::New { description: Some(description), } => { @@ -54,11 +58,13 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<( issue.set_description(description)?; println!("created new issue '{}'", issue.title()); } + Commands::New { description: None } => { let mut issue = entomologist::issue::Issue::new(issues_dir)?; issue.edit_description()?; println!("created new issue '{}'", issue.title()); } + Commands::Edit { issue_id } => { let mut issues = entomologist::issues::Issues::new_from_dir(std::path::Path::new(issues_dir))?; @@ -67,10 +73,11 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<( issue.edit_description()?; } None => { - println!("issue {} not found", issue_id); + return Err(anyhow::anyhow!("issue {} not found", issue_id)); } } } + Commands::Show { issue_id } => { let issues = entomologist::issues::Issues::new_from_dir(std::path::Path::new(issues_dir))?; @@ -85,17 +92,20 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<( println!("{}", issue.description); } None => { - println!("issue {} not found", issue_id); + return Err(anyhow::anyhow!("issue {} not found", issue_id)); } } } - Commands::State { issue_id, new_state } => { + + Commands::State { + issue_id, + new_state, + } => { let mut issues = entomologist::issues::Issues::new_from_dir(std::path::Path::new(issues_dir))?; match issues.issues.get_mut(issue_id) { Some(issue) => { - let current_state = issue.state.clone(); - + let current_state = issue.state.clone(); match new_state { Some(s) => { issue.set_state(s.clone())?; @@ -107,10 +117,9 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<( println!("state: {}", current_state); } } - } None => { - println!("issue {} not found", issue_id); + return Err(anyhow::anyhow!("issue {} not found", issue_id)); } } }