diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-06-06 21:09:58 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-06-06 21:09:58 +0200 |
commit | f7f4add2c8bb7334574f3a54fbb3510288ffd2e1 (patch) | |
tree | b78d21b6cf2651431d13a12e911968017bef4540 | |
parent | {modules,pkgs}/qutebrowser: Enable qutebrowser support (diff) | |
download | nixos-config-f7f4add2c8bb7334574f3a54fbb3510288ffd2e1.zip |
pkgs/tskm: Support filtering the show `inputs` in `tskm inputs list`
-rw-r--r-- | pkgs/by-name/ts/tskm/src/cli.rs | 10 | ||||
-rw-r--r-- | pkgs/by-name/ts/tskm/src/interface/input/handle.rs | 12 |
2 files changed, 17 insertions, 5 deletions
diff --git a/pkgs/by-name/ts/tskm/src/cli.rs b/pkgs/by-name/ts/tskm/src/cli.rs index ac8f8ee9..0e32fa62 100644 --- a/pkgs/by-name/ts/tskm/src/cli.rs +++ b/pkgs/by-name/ts/tskm/src/cli.rs @@ -8,10 +8,10 @@ // You should have received a copy of the License along with this program. // If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. -use std::{ffi::OsStr, path::PathBuf}; +use std::{ffi::OsStr, fmt::Display, path::PathBuf}; use anyhow::{bail, Result}; -use clap::{builder::StyledStr, ArgAction, Parser, Subcommand}; +use clap::{builder::StyledStr, ArgAction, Parser, Subcommand, ValueEnum}; use clap_complete::{ArgValueCompleter, CompletionCandidate}; use url::Url; @@ -174,7 +174,11 @@ pub enum InputCommand { }, /// List all the previously added inputs. - List, + List { + /// Only list the inputs that have all the specified tags + #[arg(add = ArgValueCompleter::new(complete_tag))] + tags: Vec<Tag>, + }, } 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 09827fca..0469870c 100644 --- a/pkgs/by-name/ts/tskm/src/interface/input/handle.rs +++ b/pkgs/by-name/ts/tskm/src/interface/input/handle.rs @@ -126,8 +126,16 @@ pub fn handle(command: InputCommand) -> Result<()> { info!("Waiting for firefox to stop"); handle.join().expect("Should be joinable")?; } - InputCommand::List => { - for url in Input::all()? { + InputCommand::List { tags } => { + let mut tag_set = HashSet::with_capacity(tags.len()); + for tag in tags { + tag_set.insert(tag); + } + + for url in Input::all()? + .iter() + .filter(|input| tag_set.is_subset(&input.tags)) + { println!("{url}"); } } |