Summarize tasks nicely in console output
This commit is contained in:
@@ -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()))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user