diff options
-rw-r--r-- | pkgs/by-name/ts/tskm/src/interface/open/handle.rs | 25 |
1 files changed, 17 insertions, 8 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 08bd1de4..dc0d165d 100644 --- a/pkgs/by-name/ts/tskm/src/interface/open/handle.rs +++ b/pkgs/by-name/ts/tskm/src/interface/open/handle.rs @@ -8,7 +8,7 @@ use crate::{cli::OpenCommand, rofi, task}; pub fn handle(command: OpenCommand) -> Result<()> { match command { OpenCommand::Review => { - for project in task::Project::all()? { + 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(|| { @@ -29,14 +29,18 @@ pub fn handle(command: OpenCommand) -> Result<()> { OpenCommand::Project { project } => { let project = if let Some(p) = project { p - } else if let Some(p) = task::Project::get_current()? { + } else if let Some(p) = + task::Project::get_current().context("Failed to get currently focused project")? + { p } else { bail!("You need to either supply a project or have a project active!"); }; project.touch().context("Failed to touch project")?; - open_in_browser(&project).context("Failed to open project")?; + open_in_browser(&project).with_context(|| { + format!("Failed to open project: {}", project.to_project_display()) + })?; } OpenCommand::Select => { let selected_project: task::Project = task::Project::from_project_string( @@ -145,7 +149,8 @@ fn open_in_browser(selected_project: &task::Project) -> Result<()> { "Starting task {} -> tracking", selected_project.to_project_display() ); - task.start()?; + task.start() + .with_context(|| format!("Failed to start task {task}"))?; } tracking_task }; @@ -164,16 +169,20 @@ fn open_in_browser(selected_project: &task::Project) -> Result<()> { } if let Some(task) = tracking_task { - task.stop()?; + task.stop() + .with_context(|| format!("Failed to stop task {task}"))?; } if let Some(task) = old_task { - task.start()?; + task.start() + .with_context(|| format!("Failed to start task {task}"))?; } if let Some(project) = old_project { - project.activate()?; + project.activate().with_context(|| { + format!("Failed to active project {}", project.to_project_display()) + })?; } else { - task::Project::clear()?; + task::Project::clear().context("Failed to clear currently focused project")?; } Ok(()) |