add State command to CLI
This commit is contained in:
parent
a6d2f7d1e8
commit
0f46eb7817
1 changed files with 18 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
|
use entomologist::issue::State;
|
||||||
#[cfg(feature = "log")]
|
#[cfg(feature = "log")]
|
||||||
use simple_logger;
|
use simple_logger;
|
||||||
|
|
||||||
|
|
@ -32,6 +33,9 @@ enum Commands {
|
||||||
|
|
||||||
/// Show the full description of an issue.
|
/// Show the full description of an issue.
|
||||||
Show { issue_id: String },
|
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<()> {
|
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(())
|
Ok(())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue