diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-06-02 12:42:07 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-06-02 12:42:49 +0200 |
commit | 9545aa2e0305ba970380f358eb043cdf13b85ac7 (patch) | |
tree | 9d723121172b9cf41aa654a4fd3fe162778e14fd /pkgs/by-name/ts/tskm/src/cli.rs | |
parent | pkgs/tskm/input/handle: Use types to contain parsing and dry code (diff) | |
download | nixos-config-9545aa2e0305ba970380f358eb043cdf13b85ac7.zip |
pkgs/tskm/cli::input::file: Support adding default tags to file import prime
Diffstat (limited to 'pkgs/by-name/ts/tskm/src/cli.rs')
-rw-r--r-- | pkgs/by-name/ts/tskm/src/cli.rs | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/pkgs/by-name/ts/tskm/src/cli.rs b/pkgs/by-name/ts/tskm/src/cli.rs index a1dd2d8e..ac8f8ee9 100644 --- a/pkgs/by-name/ts/tskm/src/cli.rs +++ b/pkgs/by-name/ts/tskm/src/cli.rs @@ -16,7 +16,10 @@ use clap_complete::{ArgValueCompleter, CompletionCandidate}; use url::Url; use crate::{ - interface::{input::Input, project::ProjectName}, + interface::{ + input::{Input, Tag}, + project::ProjectName, + }, state, task, }; @@ -153,7 +156,14 @@ pub enum InputCommand { /// Add all URLs in the file as inputs to be categorized. /// /// This expects each line to contain one URL. - File { file: PathBuf }, + File { + /// The file to read from. + file: PathBuf, + + /// Additional tags to apply to every read URL in the file. + #[arg(add = ArgValueCompleter::new(complete_tag))] + tags: Vec<Tag>, + }, /// Like 'review', but for the inputs that have previously been added. /// It takes a project in which to open the URLs. @@ -272,3 +282,27 @@ fn complete_input_url(current: &OsStr) -> Vec<CompletionCandidate> { output } +fn complete_tag(current: &OsStr) -> Vec<CompletionCandidate> { + let mut output = vec![]; + + let Some(current) = current.to_str() else { + return output; + }; + + if !current.starts_with('+') { + output.push(CompletionCandidate::new(format!("+{current}"))); + } + + output +} + +#[cfg(test)] +mod test { + use clap::CommandFactory; + + use super::CliArgs; + #[test] + fn verify_cli() { + CliArgs::command().debug_assert(); + } +} |