Add User Control Over State Transitions #7

Merged
seb merged 4 commits from 03/state-transitions into main 2025-07-07 18:13:07 -06:00
Showing only changes of commit 0f46eb7817 - Show all commits

View file

@ -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(())