Summarize tasks nicely in console output

This commit is contained in:
Dustin J. Mitchell
2021-05-30 16:36:20 -04:00
parent adfde8be15
commit 9e3646bf84
3 changed files with 20 additions and 9 deletions

View File

@@ -2,7 +2,7 @@
use crate::argparse::{Command, Subcommand};
use crate::settings::Settings;
use taskchampion::{Replica, Server, ServerConfig, StorageConfig, Uuid};
use taskchampion::{Replica, Server, ServerConfig, StorageConfig, Task, Uuid};
use termcolor::{ColorChoice, StandardStream};
mod cmd;
@@ -149,3 +149,14 @@ fn get_writer() -> StandardStream {
ColorChoice::Never
})
}
/// Summarize a task in a single line
fn summarize_task(replica: &mut Replica, task: &Task) -> anyhow::Result<String> {
let ws = replica.working_set()?;
let uuid = task.get_uuid();
if let Some(id) = ws.by_uuid(uuid) {
Ok(format!("{} - {}", id, task.get_description()))
} else {
Ok(format!("{} - {}", uuid, task.get_description()))
}
}