style: reformat

This commit is contained in:
xeruf 2024-07-31 20:08:33 +03:00
parent 03263840ac
commit afd6f2f77a
3 changed files with 17 additions and 23 deletions

View File

@ -190,8 +190,7 @@ async fn main() {
" {}{}) ",
tasks.get_task_path(tasks.get_position()),
tasks.get_prompt_suffix()
)
.italic()
).italic()
);
stdout().flush().unwrap();
match lines.next() {
@ -239,7 +238,7 @@ async fn main() {
}
}
None => {
if arg.is_empty() {
if arg.is_empty() {
println!("Available properties:
- `id`
- `parentid`

View File

@ -49,7 +49,7 @@ impl Task {
.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| {
if event.kind == Kind::TextNote {
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| {
event.kind.try_into().ok().map(|s| TaskState {
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 {
self.state == State::Active
|| self
.name
.as_ref()
.is_some_and(|n| n.eq_ignore_ascii_case(label))
|| self.name.as_ref().is_some_and(|n| n.eq_ignore_ascii_case(label))
|| self.state.to_string().eq_ignore_ascii_case(label)
}
}

View File

@ -198,19 +198,18 @@ impl Tasks {
self.traverse_up_from(Some(id))
.take_while(|t| Some(t.event.id) != self.position),
false,
)
.unwrap_or(id.to_string())
).unwrap_or(id.to_string())
}
// 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)
}
fn resolve_tasks_rec<'a>(
&self,
iter: impl IntoIterator<Item = &'a EventId>,
iter: impl IntoIterator<Item=&'a EventId>,
depth: i8,
) -> Vec<&Task> {
iter.into_iter()
@ -266,18 +265,17 @@ impl Tasks {
.values()
.filter(|t| t.parent_id() == self.position)
.map(|t| t.get_id()),
)
.into_iter()
.filter(|t| {
self.state.as_ref().map_or(true, |state| {
t.state().is_some_and(|t| t.matches_label(state))
}) && (self.tags.is_empty()
|| t.tags.as_ref().map_or(false, |tags| {
).into_iter()
.filter(|t| {
self.state.as_ref().map_or(true, |state| {
t.state().is_some_and(|t| t.matches_label(state))
}) && (self.tags.is_empty()
|| t.tags.as_ref().map_or(false, |tags| {
let mut iter = tags.iter();
self.tags.iter().all(|tag| iter.any(|t| t == tag))
}))
})
.collect()
})
.collect()
}
pub(crate) fn print_tasks(&self) -> Result<(), Error> {
@ -373,7 +371,7 @@ impl Tasks {
pub(crate) fn move_to(&mut self, id: Option<EventId>) {
self.view.clear();
self.tags.clear();
self.tags.clear(); // TODO unsure if this is needed, needs alternative way to clear
if id == self.position {
return;
}