forked from janek/mostr
1
0
Fork 0

style: reformat code

This commit is contained in:
xeruf 2024-08-08 13:52:02 +03:00
parent a3a732879f
commit 79b42b8df0
4 changed files with 21 additions and 19 deletions

View File

@ -41,17 +41,17 @@ pub(crate) fn build_task(name: &str, tags: Vec<Tag>) -> 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(),
)
}
}

View File

@ -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::<i8>() {
@ -440,7 +441,7 @@ async fn main() {
selected_relay = new_relay;
}
//or_print(tasks.print_tasks());
continue
continue;
} else {
tasks.filter_or_create(&input);
}

View File

@ -58,7 +58,7 @@ impl Task {
}
})
}
pub(crate) fn descriptions(&self) -> impl Iterator<Item=&String> + '_ {
self.description_events().map(|e| &e.content)
}

View File

@ -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<Item=&str> {
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(),