aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/ts/tskm/src/interface/open
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-04-06 18:36:27 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-04-06 18:38:03 +0200
commita9db63802db2293ac4ee280394568b09f6feaa87 (patch)
tree32b00aa17fda1bf11bf87fdefa71b77d2bc44348 /pkgs/by-name/ts/tskm/src/interface/open
parentfix(modules/taskwarrior/mkHook): Use correct `grep` silencing argument (diff)
downloadnixos-config-a9db63802db2293ac4ee280394568b09f6feaa87.zip
feat(pkgs/tskm/task): Use taskchampion instead of run_task
Diffstat (limited to '')
-rw-r--r--pkgs/by-name/ts/tskm/src/interface/open/handle.rs27
1 files changed, 13 insertions, 14 deletions
diff --git a/pkgs/by-name/ts/tskm/src/interface/open/handle.rs b/pkgs/by-name/ts/tskm/src/interface/open/handle.rs
index dc0d165d..0b565abd 100644
--- a/pkgs/by-name/ts/tskm/src/interface/open/handle.rs
+++ b/pkgs/by-name/ts/tskm/src/interface/open/handle.rs
@@ -3,15 +3,15 @@ use std::process;
use anyhow::{bail, Context, Result};
use log::{error, info};
-use crate::{cli::OpenCommand, rofi, task};
+use crate::{cli::OpenCommand, rofi, state::State, task};
-pub fn handle(command: OpenCommand) -> Result<()> {
+pub fn handle(command: OpenCommand, state: &mut State) -> Result<()> {
match command {
OpenCommand::Review => {
for project in task::Project::all().context("Failed to get all project files")? {
if project.is_touched() {
info!("Reviewing project: '{}'", project.to_project_display());
- open_in_browser(project).with_context(|| {
+ open_in_browser(project, state).with_context(|| {
format!(
"Failed to open project ('{}') in Firefox",
project.to_project_display()
@@ -38,7 +38,7 @@ pub fn handle(command: OpenCommand) -> Result<()> {
};
project.touch().context("Failed to touch project")?;
- open_in_browser(&project).with_context(|| {
+ open_in_browser(&project, state).with_context(|| {
format!("Failed to open project: {}", project.to_project_display())
})?;
}
@@ -60,7 +60,7 @@ pub fn handle(command: OpenCommand) -> Result<()> {
.touch()
.context("Failed to touch project")?;
- open_in_browser(&selected_project).context("Failed to open project")?;
+ open_in_browser(&selected_project, state).context("Failed to open project")?;
}
OpenCommand::ListTabs { project } => {
let project = if let Some(p) = project {
@@ -109,12 +109,11 @@ pub fn handle(command: OpenCommand) -> Result<()> {
Ok(())
}
-fn open_in_browser(selected_project: &task::Project) -> Result<()> {
+fn open_in_browser(selected_project: &task::Project, state: &mut State) -> Result<()> {
let old_project: Option<task::Project> =
task::Project::get_current().context("Failed to get currently active project")?;
- // We have ensured that only one task may be active
- let old_task: Option<task::Id> =
- task::Id::get_current().context("Failed to get currently active task")?;
+ let old_task: Option<task::Task> =
+ task::Task::get_current(state).context("Failed to get currently active task")?;
selected_project.activate().with_context(|| {
format!(
@@ -124,7 +123,7 @@ fn open_in_browser(selected_project: &task::Project) -> Result<()> {
})?;
let tracking_task = {
- let all_tasks = selected_project.get_tasks().with_context(|| {
+ let all_tasks = selected_project.get_tasks(state).with_context(|| {
format!(
"Failed to get assoctiated tasks for project: '{}'",
selected_project.to_project_display()
@@ -132,7 +131,7 @@ fn open_in_browser(selected_project: &task::Project) -> Result<()> {
})?;
let tracking_task = all_tasks.into_iter().find(|t| {
- let maybe_desc = t.description();
+ let maybe_desc = t.description(state);
if let Ok(desc) = maybe_desc {
desc == "tracking"
} else {
@@ -149,7 +148,7 @@ fn open_in_browser(selected_project: &task::Project) -> Result<()> {
"Starting task {} -> tracking",
selected_project.to_project_display()
);
- task.start()
+ task.start(state)
.with_context(|| format!("Failed to start task {task}"))?;
}
tracking_task
@@ -169,11 +168,11 @@ fn open_in_browser(selected_project: &task::Project) -> Result<()> {
}
if let Some(task) = tracking_task {
- task.stop()
+ task.stop(state)
.with_context(|| format!("Failed to stop task {task}"))?;
}
if let Some(task) = old_task {
- task.start()
+ task.start(state)
.with_context(|| format!("Failed to start task {task}"))?;
}