update CLI to have optional state control

This commit is contained in:
sigil-03 2025-07-07 16:49:25 -06:00
parent 0f46eb7817
commit bcc8ba4f21

View file

@ -35,7 +35,7 @@ enum Commands {
Show { issue_id: String },
/// Modify the state of an issue
State { issue_id: String, new_state: State },
State { issue_id: String, new_state: Option<State> },
}
fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<()> {
@ -91,9 +91,20 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<(
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);
let current_state = issue.state.clone();
match new_state {
Some(s) => {
issue.set_state(s.clone())?;
println!("issue: {}", issue_id);
println!("state: {} -> {}", current_state, s);
}
None => {
println!("issue: {}", issue_id);
println!("state: {}", current_state);
}
}
}
None => {
println!("issue {} not found", issue_id);