From 79b42b8df0467cbd56aa37c28dabc7766f4fb52e Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Thu, 8 Aug 2024 13:52:02 +0300 Subject: [PATCH] style: reformat code --- src/kinds.rs | 14 +++++++------- src/main.rs | 17 +++++++++-------- src/task.rs | 2 +- src/tasks.rs | 7 ++++--- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/kinds.rs b/src/kinds.rs index 6f23a98..1bf2aee 100644 --- a/src/kinds.rs +++ b/src/kinds.rs @@ -41,17 +41,17 @@ pub(crate) fn build_task(name: &str, tags: Vec) -> EventBuilder { fn format_tag(tag: &Tag) -> String { match tag.as_standardized() { Some(TagStandard::Event { - event_id, - .. - }) => format!("Parent: {}", event_id.to_string()[..8].to_string()), + event_id, + .. + }) => format!("Parent: {}", event_id.to_string()[..8].to_string()), Some(TagStandard::PublicKey { - public_key, - .. - }) => format!("Key: {}", public_key.to_string()[..8].to_string()), + public_key, + .. + }) => format!("Key: {}", public_key.to_string()[..8].to_string()), Some(TagStandard::Hashtag(content)) => format!("#{content}"), _ => tag.content().map_or_else( || format!("Kind {}", tag.kind()), - |content| content.to_string() + |content| content.to_string(), ) } } diff --git a/src/main.rs b/src/main.rs index e9f572e..d37ce34 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,8 +8,9 @@ use std::ops::Sub; use std::path::PathBuf; use std::str::FromStr; use std::sync::mpsc; -use std::sync::mpsc::{Sender}; -use chrono::{DateTime}; +use std::sync::mpsc::Sender; + +use chrono::DateTime; use colored::Colorize; use itertools::Itertools; use log::{debug, error, info, trace, warn}; @@ -290,7 +291,7 @@ async fn main() { tasks.add_or_remove_property_column(arg); } else { println!("{}", PROPERTY_COLUMNS); - continue + continue; }, Some(',') => { @@ -300,8 +301,8 @@ async fn main() { || info!("With a task selected, use ,NOTE to attach NOTE and , to list all its notes"), |task| println!("{}", task.description_events().map(|e| format!("{} {}", e.created_at.to_human_datetime(), e.content)).join("\n")), ); - continue - }, + continue; + } Some(arg) => tasks.make_note(arg), } } @@ -336,7 +337,7 @@ async fn main() { Some(arg) => tasks.set_tag(arg.to_string()), None => { println!("Hashtags of all known tasks:\n{}", tasks.all_hashtags().join(" ")); - continue + continue; } } } @@ -381,7 +382,7 @@ async fn main() { let slice = &input[dots..]; tasks.move_to(pos); if slice.is_empty() { - if dots > 1 { + if dots > 1 { info!("Moving up {} tasks", dots - 1) } } else if let Ok(depth) = slice.parse::() { @@ -440,7 +441,7 @@ async fn main() { selected_relay = new_relay; } //or_print(tasks.print_tasks()); - continue + continue; } else { tasks.filter_or_create(&input); } diff --git a/src/task.rs b/src/task.rs index 5da68a1..d47714b 100644 --- a/src/task.rs +++ b/src/task.rs @@ -58,7 +58,7 @@ impl Task { } }) } - + pub(crate) fn descriptions(&self) -> impl Iterator + '_ { self.description_events().map(|e| &e.content) } diff --git a/src/tasks.rs b/src/tasks.rs index 8996095..13322d5 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -1,9 +1,10 @@ use std::collections::{BTreeSet, HashMap}; use std::io::{Error, stdout, Write}; -use std::iter::{once, Sum}; +use std::iter::once; use std::ops::{Div, Rem}; use std::sync::mpsc::Sender; use std::time::Duration; + use chrono::{DateTime, Local, TimeZone}; use chrono::LocalResult::Single; use colored::Colorize; @@ -102,7 +103,7 @@ impl Tasks { children } - + pub(crate) fn all_hashtags(&self) -> impl Iterator { self.tasks.values() .filter(|t| t.pure_state() != State::Closed) @@ -594,7 +595,7 @@ impl Tasks { _ => State::Open, }); } - + pub(crate) fn set_state_for(&mut self, id: EventId, comment: &str, state: State) -> EventId { let prop = self.build_prop( state.into(),