diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-06-11 13:04:16 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-06-11 13:04:16 +0200 |
commit | 81ed60e6eb0ae2f0aa06eb6859b5d76d6841519a (patch) | |
tree | 23d253fb37c70a70ab4a0abde47ba53b58f9d48e /pkgs/by-name/ts/tskm/src/interface/open | |
parent | pkgs/tskm/neorg/task: Correctly call the id argument “task” (diff) | |
download | nixos-config-81ed60e6eb0ae2f0aa06eb6859b5d76d6841519a.zip |
pkgs/tskm/open/review: All reviewing all non-empty projects
Diffstat (limited to 'pkgs/by-name/ts/tskm/src/interface/open')
-rw-r--r-- | pkgs/by-name/ts/tskm/src/interface/open/handle.rs | 28 |
1 files changed, 25 insertions, 3 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 231545b6..ca54b422 100644 --- a/pkgs/by-name/ts/tskm/src/interface/open/handle.rs +++ b/pkgs/by-name/ts/tskm/src/interface/open/handle.rs @@ -14,18 +14,40 @@ use url::Url; use crate::{browser::open_in_browser, cli::OpenCommand, rofi, state::State, task}; +fn is_empty(project: &task::Project) -> Result<bool> { + let tabs = get_tabs(project)?; + + Ok(tabs.is_empty()) +} + +#[allow(clippy::too_many_lines)] pub fn handle(command: OpenCommand, state: &mut State) -> Result<()> { match command { - OpenCommand::Review => { + OpenCommand::Review { non_empty } => { for project in task::Project::all().context("Failed to get all project files")? { - if project.is_touched() { - info!("Reviewing project: '{}'", project.to_project_display()); + let is_empty = is_empty(project)?; + + if project.is_touched() || (non_empty && !is_empty) { + info!( + "Reviewing project: '{}' ({})", + project.to_project_display(), + if is_empty { "is empty" } else { "is not empty" } + ); open_in_browser(project, state, None).with_context(|| { format!( "Failed to open project ('{}') in qutebrowser", project.to_project_display() ) })?; + + if project.is_touched() { + project.untouch().with_context(|| { + format!( + "Failed to untouch project ('{}')", + project.to_project_display() + ) + })?; + } } } } |