diff --git a/src/bin/ent/main.rs b/src/bin/ent/main.rs index d26dc3c..6a3c9f0 100644 --- a/src/bin/ent/main.rs +++ b/src/bin/ent/main.rs @@ -1,5 +1,6 @@ use clap::Parser; +use entomologist::issue::State; #[cfg(feature = "log")] use simple_logger; @@ -32,6 +33,9 @@ enum Commands { /// Show the full description of an issue. Show { issue_id: String }, + + /// Modify the state of an issue + State { issue_id: String, new_state: State }, } fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<()> { @@ -82,6 +86,20 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<( } } } + 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 old_state = issue.state.clone(); + issue.set_state(new_state.clone())?; + println!("issue {}: state {} -> {}", issue_id, old_state, new_state); + } + None => { + println!("issue {} not found", issue_id); + } + } + } } Ok(())