feat(main): show all task updates with comma

This commit is contained in:
xeruf 2024-11-19 17:09:59 +01:00
parent cb1d8ef8fb
commit 00bd7a997a

View file

@ -3,14 +3,15 @@ use std::env::{args, var};
use std::fs; use std::fs;
use std::fs::File; use std::fs::File;
use std::io::{BufRead, BufReader, Write}; use std::io::{BufRead, BufReader, Write};
use std::iter::once;
use std::path::PathBuf; use std::path::PathBuf;
use std::str::FromStr; use std::str::FromStr;
use std::time::Duration; use std::time::Duration;
use crate::event_sender::MostrMessage; use crate::event_sender::MostrMessage;
use crate::helpers::*; use crate::helpers::*;
use crate::kinds::{Prio, BASIC_KINDS, PROPERTY_COLUMNS, PROP_KINDS}; use crate::kinds::{join, match_event_tag, Prio, BASIC_KINDS, PROPERTY_COLUMNS, PROP_KINDS};
use crate::task::{State, Task, TaskState}; use crate::task::{State, Task, TaskState, MARKER_PROPERTY};
use crate::tasks::{PropertyCollection, StateFilter, TasksRelay}; use crate::tasks::{PropertyCollection, StateFilter, TasksRelay};
use chrono::Local; use chrono::Local;
use colored::Colorize; use colored::Colorize;
@ -384,17 +385,27 @@ async fn main() -> Result<()> {
match arg { match arg {
None => { None => {
if let Some(task) = tasks.get_current_task() { if let Some(task) = tasks.get_current_task() {
let mut desc = task.description_events().peekable(); for e in once(&task.event).chain(task.props.iter().rev()) {
if desc.peek().is_some() { let content = match State::try_from(e.kind) {
println!("{}", Ok(state) => {
desc.map(|e| format!("{} {}", format_timestamp_local(&e.created_at), e.content)) format!("State: {state}{}",
.join("\n")); if e.content.is_empty() { String::new() } else { format!(" - {}", e.content) })
continue 'repl; }
Err(_) => {
e.content.to_string()
}
};
println!("{} {} [{}]",
format_timestamp_local(&e.created_at),
content,
join(e.tags.iter().filter(|t| match_event_tag(t).unwrap().marker.is_none_or(|m| m != MARKER_PROPERTY))));
} }
continue 'repl;
} else {
info!("With a task selected, use ,NOTE to attach NOTE and , to list all its updates");
tasks.recurse_activities = !tasks.recurse_activities;
info!("Toggled activities recursion to {}", tasks.recurse_activities);
} }
info!("With a task selected, use ,NOTE to attach NOTE and , to list all its notes");
tasks.recurse_activities = !tasks.recurse_activities;
info!("Toggled activities recursion to {}", tasks.recurse_activities);
} }
Some(arg) => { Some(arg) => {
if arg.len() < CHARACTER_THRESHOLD { if arg.len() < CHARACTER_THRESHOLD {