diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-04-06 18:36:27 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-04-06 18:38:03 +0200 |
commit | a9db63802db2293ac4ee280394568b09f6feaa87 (patch) | |
tree | 32b00aa17fda1bf11bf87fdefa71b77d2bc44348 /pkgs/by-name/ts/tskm/src/cli.rs | |
parent | fix(modules/taskwarrior/mkHook): Use correct `grep` silencing argument (diff) | |
download | nixos-config-a9db63802db2293ac4ee280394568b09f6feaa87.zip |
feat(pkgs/tskm/task): Use taskchampion instead of run_task
Diffstat (limited to 'pkgs/by-name/ts/tskm/src/cli.rs')
-rw-r--r-- | pkgs/by-name/ts/tskm/src/cli.rs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/pkgs/by-name/ts/tskm/src/cli.rs b/pkgs/by-name/ts/tskm/src/cli.rs index 99c8693e..bc79866a 100644 --- a/pkgs/by-name/ts/tskm/src/cli.rs +++ b/pkgs/by-name/ts/tskm/src/cli.rs @@ -1,9 +1,11 @@ use std::path::PathBuf; -use clap::{Parser, Subcommand}; +use anyhow::{bail, Result}; +use clap::{ArgAction, Parser, Subcommand}; use crate::{ interface::{input::Input, project::ProjectName}, + state::State, task, }; @@ -66,7 +68,21 @@ pub enum ProjectCommand { #[derive(Subcommand, Debug, Clone, Copy)] pub enum NeorgCommand { /// Open the `neorg` project associated with id of the task. - Task { id: task::Id }, + Task { + /// The working set id of the task + #[arg(value_parser = task_from_working_set_id)] + id: task::Task, + }, +} + +fn task_from_working_set_id(id: &str) -> Result<task::Task> { + let id: usize = id.parse()?; + let mut state = State::new_ro()?; + + let Some(task) = task::Task::from_working_set(id, &mut state)? else { + bail!("Working set id '{id}' is not valid!") + }; + Ok(task) } #[derive(Subcommand, Debug)] |