summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2021-03-11 14:08:58 +0100
committerJustus Winter <justus@sequoia-pgp.org>2021-03-11 14:08:58 +0100
commitefcf130fb2635848a609fb7d897aa0258bfaa9a2 (patch)
tree47055bfc7b0191c940eff045056f4aed6108bae9
parenta2c8d4f1e8214f3873020f7042e67cb4d9381668 (diff)
sq: Implement keyring filter --userid.
- Fixes #689.
-rw-r--r--sq/src/commands/keyring.rs9
-rw-r--r--sq/src/sq-usage.rs3
-rw-r--r--sq/src/sq_cli.rs7
3 files changed, 18 insertions, 1 deletions
diff --git a/sq/src/commands/keyring.rs b/sq/src/commands/keyring.rs
index 04ae90b9..bb561c8e 100644
--- a/sq/src/commands/keyring.rs
+++ b/sq/src/commands/keyring.rs
@@ -34,12 +34,19 @@ pub fn dispatch(config: Config, m: &clap::ArgMatches) -> Result<()> {
match m.subcommand() {
("filter", Some(m)) => {
let any_uid_predicates =
- m.is_present("name")
+ m.is_present("userid")
+ || m.is_present("name")
|| m.is_present("email")
|| m.is_present("domain");
let uid_predicate = |uid: &UserID| {
let mut keep = false;
+ if let Some(userids) = m.values_of("userid") {
+ for userid in userids {
+ keep |= uid.value() == userid.as_bytes();
+ }
+ }
+
if let Some(names) = m.values_of("name") {
for name in names {
keep |= uid
diff --git a/sq/src/sq-usage.rs b/sq/src/sq-usage.rs
index b8c71cda..bd7acefb 100644
--- a/sq/src/sq-usage.rs
+++ b/sq/src/sq-usage.rs
@@ -824,6 +824,9 @@
//! -o, --output <FILE>
//! Writes to FILE or stdout if omitted
//!
+//! --userid <USERID>...
+//! Case-sensitively matches on the user id, requiring an exact match.
+//!
//!
//! ARGS:
//! <FILE>...
diff --git a/sq/src/sq_cli.rs b/sq/src/sq_cli.rs
index 5c1a2970..c76758ba 100644
--- a/sq/src/sq_cli.rs
+++ b/sq/src/sq_cli.rs
@@ -776,6 +776,13 @@ $ sq keyring filter --domain example.org --prune-certs certs.pgp
.arg(Arg::with_name("output")
.short("o").long("output").value_name("FILE")
.help("Writes to FILE or stdout if omitted"))
+ .arg(Arg::with_name("userid")
+ .long("userid").value_name("USERID")
+ .multiple(true).number_of_values(1)
+ .help("Matches on USERID")
+ .long_help(
+ "Case-sensitively matches on the \
+ user id, requiring an exact match."))
.arg(Arg::with_name("name")
.long("name").value_name("NAME")
.multiple(true).number_of_values(1)