diff options
Diffstat (limited to 'pkgs/by-name/ts/tskm/src/interface/neorg/handle.rs')
-rw-r--r-- | pkgs/by-name/ts/tskm/src/interface/neorg/handle.rs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/pkgs/by-name/ts/tskm/src/interface/neorg/handle.rs b/pkgs/by-name/ts/tskm/src/interface/neorg/handle.rs index 194e3926..ea3a89ae 100644 --- a/pkgs/by-name/ts/tskm/src/interface/neorg/handle.rs +++ b/pkgs/by-name/ts/tskm/src/interface/neorg/handle.rs @@ -10,19 +10,19 @@ use std::{ env, - fs::{self, File, OpenOptions, read_to_string}, + fs::{self, read_to_string, File, OpenOptions}, io::Write, process::Command, }; -use anyhow::{Context, Result, bail}; +use anyhow::{bail, Context, Result}; use crate::{cli::NeorgCommand, state::State}; pub fn handle(command: NeorgCommand, state: &mut State) -> Result<()> { match command { - NeorgCommand::Task { id } => { - let project = id.project(state)?; + NeorgCommand::Task { task } => { + let project = task.project(state)?; let base = dirs::data_local_dir() .expect("This should exists") .join("tskm/notes"); @@ -40,15 +40,17 @@ pub fn handle(command: NeorgCommand, state: &mut State) -> Result<()> { String::new() }; - if !contents.contains(format!("% {}", id.uuid()).as_str()) { + if !contents.contains(format!("% {}", task.uuid()).as_str()) { let mut options = OpenOptions::new(); options.append(true).create(false); let mut file = options.open(&path)?; - file.write_all(format!("* TITLE (% {})", id.uuid()).as_bytes()) - .with_context(|| { - format!("Failed to write task uuid to file: '{}'", path.display()) - })?; + file.write_all( + format!("* {} (% {})", task.description(state)?, task.uuid()).as_bytes(), + ) + .with_context(|| { + format!("Failed to write task uuid to file: '{}'", path.display()) + })?; file.flush() .with_context(|| format!("Failed to flush file: '{}'", path.display()))?; } @@ -59,7 +61,7 @@ pub fn handle(command: NeorgCommand, state: &mut State) -> Result<()> { .args([ path.to_str().expect("Should be a utf-8 str"), "-c", - format!("/% {}", id.uuid()).as_str(), + format!("/% {}", task.uuid()).as_str(), ]) .status()?; if !status.success() { @@ -90,7 +92,7 @@ pub fn handle(command: NeorgCommand, state: &mut State) -> Result<()> { } { - id.mark_neorg_data(state)?; + task.mark_neorg_data(state)?; } } } |