diff --git a/src/bin/ent/main.rs b/src/bin/ent/main.rs index 187d067..d26dc3c 100644 --- a/src/bin/ent/main.rs +++ b/src/bin/ent/main.rs @@ -1,6 +1,5 @@ use clap::Parser; -use entomologist::issue::State; #[cfg(feature = "log")] use simple_logger; @@ -33,9 +32,6 @@ 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: Option }, } fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<()> { @@ -86,31 +82,6 @@ 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 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); - } - } - } } Ok(()) diff --git a/src/issue.rs b/src/issue.rs index f931be3..bb8594a 100644 --- a/src/issue.rs +++ b/src/issue.rs @@ -1,11 +1,10 @@ -use core::fmt; use std::io::Write; use std::str::FromStr; #[cfg(feature = "log")] use log::debug; -#[derive(Clone, Debug, PartialEq, serde::Deserialize)] +#[derive(Debug, PartialEq, serde::Deserialize)] /// These are the states an issue can be in. pub enum State { New, @@ -63,21 +62,6 @@ impl FromStr for State { } } -impl fmt::Display for State { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let fmt_str = match self { - State::New => "new", - State::Backlog => "backlog", - State::Blocked => "blocked", - State::InProgress => "inprogress", - State::Done => "done", - State::WontDo => "wontdo", - - }; - write!(f, "{fmt_str}") - } -} - impl Issue { pub fn new_from_dir(dir: &std::path::Path) -> Result { let mut description: Option = None; @@ -173,23 +157,6 @@ impl Issue { None => self.description.as_str(), } } - - pub fn set_state(&mut self, new_state: State) -> Result<(), IssueError> { - let mut state_filename = std::path::PathBuf::from(&self.dir); - state_filename.push("state"); - let mut state_file = std::fs::File::create(&state_filename)?; - write!(state_file, "{}", new_state)?; - crate::git::git_commit_file(&state_filename)?; - Ok(()) - } - - pub fn read_state(&mut self) -> Result<(), IssueError> { - let mut state_filename = std::path::PathBuf::from(&self.dir); - state_filename.push("state"); - let state_string = std::fs::read_to_string(state_filename)?; - self.state = State::from_str(state_string.trim())?; - Ok(()) - } } #[cfg(test)]