aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/ts
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-06-11 13:05:33 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-06-11 13:05:33 +0200
commit067acf34185c7651a6220bc03a1058f65534e9f6 (patch)
tree780a205ba8f308b27f7b9c25ac5f9b96408d6fb7 /pkgs/by-name/ts
parentpkgs/tskm/open/list-tabs: All listing based on empty/non-empty and more than ... (diff)
downloadnixos-config-067acf34185c7651a6220bc03a1058f65534e9f6.zip
pkgs/tskm/inputs/tags: Init
This makes it possible to see the already used tabs.
Diffstat (limited to 'pkgs/by-name/ts')
-rw-r--r--pkgs/by-name/ts/tskm/src/cli.rs3
-rw-r--r--pkgs/by-name/ts/tskm/src/interface/input/handle.rs31
2 files changed, 34 insertions, 0 deletions
diff --git a/pkgs/by-name/ts/tskm/src/cli.rs b/pkgs/by-name/ts/tskm/src/cli.rs
index ac5f472b..90d6023b 100644
--- a/pkgs/by-name/ts/tskm/src/cli.rs
+++ b/pkgs/by-name/ts/tskm/src/cli.rs
@@ -196,6 +196,9 @@ pub enum InputCommand {
#[arg(add = ArgValueCompleter::new(complete_tag))]
tags: Vec<Tag>,
},
+
+ /// Show all the available tags.
+ Tags {},
}
fn complete_task_id(current: &OsStr) -> Vec<CompletionCandidate> {
diff --git a/pkgs/by-name/ts/tskm/src/interface/input/handle.rs b/pkgs/by-name/ts/tskm/src/interface/input/handle.rs
index 839e122f..11304633 100644
--- a/pkgs/by-name/ts/tskm/src/interface/input/handle.rs
+++ b/pkgs/by-name/ts/tskm/src/interface/input/handle.rs
@@ -111,6 +111,37 @@ pub fn handle(command: InputCommand, state: &mut State) -> Result<()> {
println!("{url}");
}
}
+ InputCommand::Tags {} => {
+ let mut without_tags = 0;
+ let mut tag_set: HashMap<Tag, u64> = HashMap::new();
+
+ for input in Input::all()? {
+ if input.tags.is_empty() {
+ without_tags += 1;
+ }
+
+ for tag in input.tags {
+ if let Some(number) = tag_set.get_mut(&tag) {
+ *number += 1;
+ } else {
+ tag_set.insert(tag, 1);
+ }
+ }
+ }
+
+ let mut tags: Vec<(Tag, u64)> = tag_set.into_iter().collect();
+ tags.sort_by_key(|(_, number)| *number);
+ tags.reverse();
+
+ for (tag, number) in tags {
+ println!("{tag} {number}");
+ }
+
+ if without_tags != 0 {
+ println!();
+ println!("Witohut tags: {without_tags}");
+ }
+ }
}
Ok(())
}