forked from janek/mostr
style: reformat code
This commit is contained in:
parent
a3a732879f
commit
79b42b8df0
14
src/kinds.rs
14
src/kinds.rs
|
@ -41,17 +41,17 @@ pub(crate) fn build_task(name: &str, tags: Vec<Tag>) -> EventBuilder {
|
||||||
fn format_tag(tag: &Tag) -> String {
|
fn format_tag(tag: &Tag) -> String {
|
||||||
match tag.as_standardized() {
|
match tag.as_standardized() {
|
||||||
Some(TagStandard::Event {
|
Some(TagStandard::Event {
|
||||||
event_id,
|
event_id,
|
||||||
..
|
..
|
||||||
}) => format!("Parent: {}", event_id.to_string()[..8].to_string()),
|
}) => format!("Parent: {}", event_id.to_string()[..8].to_string()),
|
||||||
Some(TagStandard::PublicKey {
|
Some(TagStandard::PublicKey {
|
||||||
public_key,
|
public_key,
|
||||||
..
|
..
|
||||||
}) => format!("Key: {}", public_key.to_string()[..8].to_string()),
|
}) => format!("Key: {}", public_key.to_string()[..8].to_string()),
|
||||||
Some(TagStandard::Hashtag(content)) => format!("#{content}"),
|
Some(TagStandard::Hashtag(content)) => format!("#{content}"),
|
||||||
_ => tag.content().map_or_else(
|
_ => tag.content().map_or_else(
|
||||||
|| format!("Kind {}", tag.kind()),
|
|| format!("Kind {}", tag.kind()),
|
||||||
|content| content.to_string()
|
|content| content.to_string(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
17
src/main.rs
17
src/main.rs
|
@ -8,8 +8,9 @@ use std::ops::Sub;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
use std::sync::mpsc::{Sender};
|
use std::sync::mpsc::Sender;
|
||||||
use chrono::{DateTime};
|
|
||||||
|
use chrono::DateTime;
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use log::{debug, error, info, trace, warn};
|
use log::{debug, error, info, trace, warn};
|
||||||
|
@ -290,7 +291,7 @@ async fn main() {
|
||||||
tasks.add_or_remove_property_column(arg);
|
tasks.add_or_remove_property_column(arg);
|
||||||
} else {
|
} else {
|
||||||
println!("{}", PROPERTY_COLUMNS);
|
println!("{}", PROPERTY_COLUMNS);
|
||||||
continue
|
continue;
|
||||||
},
|
},
|
||||||
|
|
||||||
Some(',') => {
|
Some(',') => {
|
||||||
|
@ -300,8 +301,8 @@ async fn main() {
|
||||||
|| info!("With a task selected, use ,NOTE to attach NOTE and , to list all its notes"),
|
|| 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")),
|
|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),
|
Some(arg) => tasks.make_note(arg),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,7 +337,7 @@ async fn main() {
|
||||||
Some(arg) => tasks.set_tag(arg.to_string()),
|
Some(arg) => tasks.set_tag(arg.to_string()),
|
||||||
None => {
|
None => {
|
||||||
println!("Hashtags of all known tasks:\n{}", tasks.all_hashtags().join(" "));
|
println!("Hashtags of all known tasks:\n{}", tasks.all_hashtags().join(" "));
|
||||||
continue
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -381,7 +382,7 @@ async fn main() {
|
||||||
let slice = &input[dots..];
|
let slice = &input[dots..];
|
||||||
tasks.move_to(pos);
|
tasks.move_to(pos);
|
||||||
if slice.is_empty() {
|
if slice.is_empty() {
|
||||||
if dots > 1 {
|
if dots > 1 {
|
||||||
info!("Moving up {} tasks", dots - 1)
|
info!("Moving up {} tasks", dots - 1)
|
||||||
}
|
}
|
||||||
} else if let Ok(depth) = slice.parse::<i8>() {
|
} else if let Ok(depth) = slice.parse::<i8>() {
|
||||||
|
@ -440,7 +441,7 @@ async fn main() {
|
||||||
selected_relay = new_relay;
|
selected_relay = new_relay;
|
||||||
}
|
}
|
||||||
//or_print(tasks.print_tasks());
|
//or_print(tasks.print_tasks());
|
||||||
continue
|
continue;
|
||||||
} else {
|
} else {
|
||||||
tasks.filter_or_create(&input);
|
tasks.filter_or_create(&input);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ impl Task {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn descriptions(&self) -> impl Iterator<Item=&String> + '_ {
|
pub(crate) fn descriptions(&self) -> impl Iterator<Item=&String> + '_ {
|
||||||
self.description_events().map(|e| &e.content)
|
self.description_events().map(|e| &e.content)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
use std::collections::{BTreeSet, HashMap};
|
use std::collections::{BTreeSet, HashMap};
|
||||||
use std::io::{Error, stdout, Write};
|
use std::io::{Error, stdout, Write};
|
||||||
use std::iter::{once, Sum};
|
use std::iter::once;
|
||||||
use std::ops::{Div, Rem};
|
use std::ops::{Div, Rem};
|
||||||
use std::sync::mpsc::Sender;
|
use std::sync::mpsc::Sender;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use chrono::{DateTime, Local, TimeZone};
|
use chrono::{DateTime, Local, TimeZone};
|
||||||
use chrono::LocalResult::Single;
|
use chrono::LocalResult::Single;
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
|
@ -102,7 +103,7 @@ impl Tasks {
|
||||||
|
|
||||||
children
|
children
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn all_hashtags(&self) -> impl Iterator<Item=&str> {
|
pub(crate) fn all_hashtags(&self) -> impl Iterator<Item=&str> {
|
||||||
self.tasks.values()
|
self.tasks.values()
|
||||||
.filter(|t| t.pure_state() != State::Closed)
|
.filter(|t| t.pure_state() != State::Closed)
|
||||||
|
@ -594,7 +595,7 @@ impl Tasks {
|
||||||
_ => State::Open,
|
_ => State::Open,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn set_state_for(&mut self, id: EventId, comment: &str, state: State) -> EventId {
|
pub(crate) fn set_state_for(&mut self, id: EventId, comment: &str, state: State) -> EventId {
|
||||||
let prop = self.build_prop(
|
let prop = self.build_prop(
|
||||||
state.into(),
|
state.into(),
|
||||||
|
|
Loading…
Reference in New Issue