diff options
Diffstat (limited to '')
-rw-r--r-- | pkgs/by-name/ts/tskm/src/task/mod.rs | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/pkgs/by-name/ts/tskm/src/task/mod.rs b/pkgs/by-name/ts/tskm/src/task/mod.rs index 03a12faa..9c671273 100644 --- a/pkgs/by-name/ts/tskm/src/task/mod.rs +++ b/pkgs/by-name/ts/tskm/src/task/mod.rs @@ -1,3 +1,13 @@ +// nixos-config - My current NixOS configuration +// +// Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de> +// SPDX-License-Identifier: GPL-3.0-or-later +// +// This file is part of my nixos-config. +// +// You should have received a copy of the License along with this program. +// If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. + use std::{ fmt::Display, fs::{self, read_to_string, File}, @@ -66,6 +76,13 @@ impl Task { pub fn uuid(&self) -> &taskchampion::Uuid { &self.uuid } + pub fn working_set_id(&self, state: &mut State) -> Result<usize> { + Ok(state + .replica() + .working_set()? + .by_uuid(self.uuid) + .expect("The task should be in the working set")) + } fn as_task(&self, state: &mut State) -> Result<taskchampion::Task> { Ok(state @@ -121,7 +138,7 @@ impl Task { .expect("Every task should have a project") .to_owned() }; - let project = Project::from_project_string(output.as_str()) + let project = Project::from_project_string(output.as_str().trim()) .expect("This comes from tw, it should be valid"); Ok(project) } @@ -338,5 +355,13 @@ pub(crate) fn run_task(args: &[&str]) -> Result<String> { trace!("Output (stdout): '{}'", stdout.trim()); trace!("Output (stderr): '{}'", stderr.trim()); + if !output.status.success() { + bail!( + "Command `task {}` failed with status: {}", + args.join(" "), + output.status + ); + } + Ok(stdout.trim().to_owned()) } |