aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/ts
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-06-11 13:04:16 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-06-11 13:04:16 +0200
commit81ed60e6eb0ae2f0aa06eb6859b5d76d6841519a (patch)
tree23d253fb37c70a70ab4a0abde47ba53b58f9d48e /pkgs/by-name/ts
parentpkgs/tskm/neorg/task: Correctly call the id argument “task” (diff)
downloadnixos-config-81ed60e6eb0ae2f0aa06eb6859b5d76d6841519a.zip
pkgs/tskm/open/review: All reviewing all non-empty projects
Diffstat (limited to 'pkgs/by-name/ts')
-rw-r--r--pkgs/by-name/ts/tskm/src/cli.rs6
-rw-r--r--pkgs/by-name/ts/tskm/src/interface/open/handle.rs28
2 files changed, 30 insertions, 4 deletions
diff --git a/pkgs/by-name/ts/tskm/src/cli.rs b/pkgs/by-name/ts/tskm/src/cli.rs
index 9175cd3d..1fd338fb 100644
--- a/pkgs/by-name/ts/tskm/src/cli.rs
+++ b/pkgs/by-name/ts/tskm/src/cli.rs
@@ -114,7 +114,11 @@ pub enum OpenCommand {
/// Open each project's Qutebrowser profile consecutively, that was opened since the last review.
///
/// This allows you to remove stale opened tabs and to commit open tabs to the `inputs`.
- Review,
+ Review {
+ /// Review all projects, if they contain tabs
+ #[arg(short, long, default_value_t)]
+ non_empty: bool,
+ },
/// Opens Qutebrowser with either the supplied project or the currently active project profile.
Project {
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()
+ )
+ })?;
+ }
}
}
}