log.rs

 1use anyhow::Result;
 2use std::path::Path;
 3
 4use crate::db;
 5use crate::ops;
 6
 7pub fn run(root: &Path, id: &str, message: &str, json: bool) -> Result<()> {
 8    let store = db::open(root)?;
 9    let task_id = db::resolve_task_id(&store, id, false)?;
10    let entry = ops::add_log(&store, &task_id, message)?;
11
12    if json {
13        println!("{}", serde_json::to_string(&entry)?);
14    } else {
15        println!("logged to {}", task_id);
16    }
17
18    Ok(())
19}