forked from janek/mostr
fix(task): properly parse str into State
This commit is contained in:
parent
b74ac18e39
commit
06bfe8e18a
13
src/task.rs
13
src/task.rs
|
@ -219,6 +219,17 @@ pub(crate) enum State {
|
|||
Pending,
|
||||
Procedure,
|
||||
}
|
||||
impl From<&str> for State {
|
||||
fn from(value: &str) -> Self {
|
||||
match value {
|
||||
"Closed" => State::Closed,
|
||||
"Done" => State::Done,
|
||||
"Pending" => State::Pending,
|
||||
"Proc" | "Procedure" | "List" => State::Procedure,
|
||||
_ => State::Open,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl TryFrom<Kind> for State {
|
||||
type Error = ();
|
||||
|
||||
|
@ -236,7 +247,7 @@ impl TryFrom<Kind> for State {
|
|||
impl State {
|
||||
pub(crate) fn is_open(&self) -> bool {
|
||||
match self {
|
||||
State::Open | State::Procedure => true,
|
||||
State::Open | State::Pending | State::Procedure => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -712,11 +712,7 @@ impl Tasks {
|
|||
}
|
||||
|
||||
pub(crate) fn set_state_for_with(&mut self, id: EventId, comment: &str) {
|
||||
self.set_state_for(id, comment, match comment {
|
||||
"Closed" => State::Closed,
|
||||
"Done" => State::Done,
|
||||
_ => State::Open,
|
||||
});
|
||||
self.set_state_for(id, comment, comment.into());
|
||||
}
|
||||
|
||||
pub(crate) fn set_state_for(&mut self, id: EventId, comment: &str, state: State) -> EventId {
|
||||
|
|
Loading…
Reference in New Issue