style: reformat
This commit is contained in:
parent
03263840ac
commit
afd6f2f77a
|
@ -190,8 +190,7 @@ async fn main() {
|
||||||
" {}{}) ",
|
" {}{}) ",
|
||||||
tasks.get_task_path(tasks.get_position()),
|
tasks.get_task_path(tasks.get_position()),
|
||||||
tasks.get_prompt_suffix()
|
tasks.get_prompt_suffix()
|
||||||
)
|
).italic()
|
||||||
.italic()
|
|
||||||
);
|
);
|
||||||
stdout().flush().unwrap();
|
stdout().flush().unwrap();
|
||||||
match lines.next() {
|
match lines.next() {
|
||||||
|
@ -239,7 +238,7 @@ async fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
if arg.is_empty() {
|
if arg.is_empty() {
|
||||||
println!("Available properties:
|
println!("Available properties:
|
||||||
- `id`
|
- `id`
|
||||||
- `parentid`
|
- `parentid`
|
||||||
|
|
|
@ -49,7 +49,7 @@ impl Task {
|
||||||
.unwrap_or_else(|| self.get_id().to_string())
|
.unwrap_or_else(|| self.get_id().to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn descriptions(&self) -> impl Iterator<Item = &String> + '_ {
|
pub(crate) fn descriptions(&self) -> impl Iterator<Item=&String> + '_ {
|
||||||
self.props.iter().filter_map(|event| {
|
self.props.iter().filter_map(|event| {
|
||||||
if event.kind == Kind::TextNote {
|
if event.kind == Kind::TextNote {
|
||||||
Some(&event.content)
|
Some(&event.content)
|
||||||
|
@ -59,7 +59,7 @@ impl Task {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn states(&self) -> impl Iterator<Item = TaskState> + '_ {
|
fn states(&self) -> impl Iterator<Item=TaskState> + '_ {
|
||||||
self.props.iter().filter_map(|event| {
|
self.props.iter().filter_map(|event| {
|
||||||
event.kind.try_into().ok().map(|s| TaskState {
|
event.kind.try_into().ok().map(|s| TaskState {
|
||||||
name: Some(event.content.clone()).filter(|c| !c.is_empty()),
|
name: Some(event.content.clone()).filter(|c| !c.is_empty()),
|
||||||
|
@ -159,10 +159,7 @@ impl TaskState {
|
||||||
}
|
}
|
||||||
pub(crate) fn matches_label(&self, label: &str) -> bool {
|
pub(crate) fn matches_label(&self, label: &str) -> bool {
|
||||||
self.state == State::Active
|
self.state == State::Active
|
||||||
|| self
|
|| self.name.as_ref().is_some_and(|n| n.eq_ignore_ascii_case(label))
|
||||||
.name
|
|
||||||
.as_ref()
|
|
||||||
.is_some_and(|n| n.eq_ignore_ascii_case(label))
|
|
||||||
|| self.state.to_string().eq_ignore_ascii_case(label)
|
|| self.state.to_string().eq_ignore_ascii_case(label)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
26
src/tasks.rs
26
src/tasks.rs
|
@ -198,19 +198,18 @@ impl Tasks {
|
||||||
self.traverse_up_from(Some(id))
|
self.traverse_up_from(Some(id))
|
||||||
.take_while(|t| Some(t.event.id) != self.position),
|
.take_while(|t| Some(t.event.id) != self.position),
|
||||||
false,
|
false,
|
||||||
)
|
).unwrap_or(id.to_string())
|
||||||
.unwrap_or(id.to_string())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
|
|
||||||
fn resolve_tasks<'a>(&self, iter: impl IntoIterator<Item = &'a EventId>) -> Vec<&Task> {
|
fn resolve_tasks<'a>(&self, iter: impl IntoIterator<Item=&'a EventId>) -> Vec<&Task> {
|
||||||
self.resolve_tasks_rec(iter, self.depth)
|
self.resolve_tasks_rec(iter, self.depth)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_tasks_rec<'a>(
|
fn resolve_tasks_rec<'a>(
|
||||||
&self,
|
&self,
|
||||||
iter: impl IntoIterator<Item = &'a EventId>,
|
iter: impl IntoIterator<Item=&'a EventId>,
|
||||||
depth: i8,
|
depth: i8,
|
||||||
) -> Vec<&Task> {
|
) -> Vec<&Task> {
|
||||||
iter.into_iter()
|
iter.into_iter()
|
||||||
|
@ -266,18 +265,17 @@ impl Tasks {
|
||||||
.values()
|
.values()
|
||||||
.filter(|t| t.parent_id() == self.position)
|
.filter(|t| t.parent_id() == self.position)
|
||||||
.map(|t| t.get_id()),
|
.map(|t| t.get_id()),
|
||||||
)
|
).into_iter()
|
||||||
.into_iter()
|
.filter(|t| {
|
||||||
.filter(|t| {
|
self.state.as_ref().map_or(true, |state| {
|
||||||
self.state.as_ref().map_or(true, |state| {
|
t.state().is_some_and(|t| t.matches_label(state))
|
||||||
t.state().is_some_and(|t| t.matches_label(state))
|
}) && (self.tags.is_empty()
|
||||||
}) && (self.tags.is_empty()
|
|| t.tags.as_ref().map_or(false, |tags| {
|
||||||
|| t.tags.as_ref().map_or(false, |tags| {
|
|
||||||
let mut iter = tags.iter();
|
let mut iter = tags.iter();
|
||||||
self.tags.iter().all(|tag| iter.any(|t| t == tag))
|
self.tags.iter().all(|tag| iter.any(|t| t == tag))
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn print_tasks(&self) -> Result<(), Error> {
|
pub(crate) fn print_tasks(&self) -> Result<(), Error> {
|
||||||
|
@ -373,7 +371,7 @@ impl Tasks {
|
||||||
|
|
||||||
pub(crate) fn move_to(&mut self, id: Option<EventId>) {
|
pub(crate) fn move_to(&mut self, id: Option<EventId>) {
|
||||||
self.view.clear();
|
self.view.clear();
|
||||||
self.tags.clear();
|
self.tags.clear(); // TODO unsure if this is needed, needs alternative way to clear
|
||||||
if id == self.position {
|
if id == self.position {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue