Compare commits

..

No commits in common. "5df03337d9e933f884b2df4ba9922a512b2e2d3e" and "bd417049065637a7766cfe1bef16ee9630b972a6" have entirely different histories.

2 changed files with 32 additions and 52 deletions

View file

@ -35,10 +35,7 @@ enum Commands {
Show { issue_id: String },
/// Modify the state of an issue
State {
issue_id: String,
new_state: Option<State>,
},
State { issue_id: String, new_state: Option<State> },
}
fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<()> {
@ -50,7 +47,6 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<(
println!("{} {} ({:?})", uuid, issue.title(), issue.state);
}
}
Commands::New {
description: Some(description),
} => {
@ -58,54 +54,45 @@ 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))?;
match issues.get_mut_issue(issue_id) {
match issues.issues.get_mut(issue_id) {
Some(issue) => {
issue.edit_description()?;
}
None => {
return Err(anyhow::anyhow!("issue {} not found", issue_id));
println!("issue {} not found", issue_id);
}
}
}
Commands::Show { issue_id } => {
let issues =
entomologist::issues::Issues::new_from_dir(std::path::Path::new(issues_dir))?;
match issues.get_issue(issue_id) {
match issues.issues.get(issue_id) {
Some(issue) => {
println!("issue {}", issue_id);
println!("state: {:?}", issue.state);
if let Some(dependencies) = &issue.dependencies {
println!("dependencies: {:?}", dependencies);
}
println!("state {:?}", issue.state);
println!("");
println!("{}", issue.description);
}
None => {
return Err(anyhow::anyhow!("issue {} not found", issue_id));
println!("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();
match new_state {
Some(s) => {
issue.set_state(s.clone())?;
@ -117,9 +104,10 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<(
println!("state: {}", current_state);
}
}
}
None => {
return Err(anyhow::anyhow!("issue {} not found", issue_id));
println!("issue {} not found", issue_id);
}
}
}

View file

@ -35,14 +35,6 @@ 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)?;