summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2022-01-21 10:25:29 +0100
committerNeal H. Walfield <neal@pep.foundation>2022-01-24 00:43:17 +0100
commitf8565a9689d2b73018ab13f80e12062309aa047b (patch)
treecca34e7c794a8972fc68bcc95a2269d4686ec2ca
parenta9e4a9d6863196bab5e2a59034fb97df70e40fd2 (diff)
sq: Allow specifying the expiration in seconds.
-rw-r--r--sq/src/sq-usage.rs9
-rw-r--r--sq/src/sq.rs9
-rw-r--r--sq/src/sq_cli.rs12
3 files changed, 16 insertions, 14 deletions
diff --git a/sq/src/sq-usage.rs b/sq/src/sq-usage.rs
index 6b05ad16..ec67191e 100644
--- a/sq/src/sq-usage.rs
+++ b/sq/src/sq-usage.rs
@@ -435,8 +435,8 @@
//! Makes the key expire at TIME (as ISO 8601). Use "never" to create
//! keys that do not expire.
//! --expires-in <DURATION>
-//! Makes the key expire after DURATION. Either "N[ymwd]", for N years,
-//! months, weeks, or days, or "never".
+//! Makes the key expire after DURATION. Either "N[ymwds]", for N years,
+//! months, weeks, days, seconds, or "never".
//! -e, --export <OUTFILE>
//! Writes the key to OUTFILE
//!
@@ -984,8 +984,9 @@
//! Makes the certification expire at TIME (as ISO 8601). Use "never" to
//! create certifications that do not expire.
//! --expires-in <DURATION>
-//! Makes the certification expire after DURATION. Either "N[ymwd]", for
-//! N years, months, weeks, or days, or "never". [default: 5y]
+//! Makes the certification expire after DURATION. Either "N[ymwds]",
+//! for N years, months, weeks, days, seconds, or "never". [default:
+//! 5y]
//! --notation <NAME> <VALUE>
//! Adds a notation to the certification. A user-defined notation's
//! name must be of the form "name@a.domain.you.control.org". If the
diff --git a/sq/src/sq.rs b/sq/src/sq.rs
index ca95775d..8c4beff3 100644
--- a/sq/src/sq.rs
+++ b/sq/src/sq.rs
@@ -106,16 +106,17 @@ fn parse_duration(expiry: &str) -> Result<Duration> {
Some('m') | Some('M') => SECONDS_IN_YEAR / 12,
Some('w') | Some('W') => 7 * SECONDS_IN_DAY,
Some('d') | Some('D') => SECONDS_IN_DAY,
+ Some('s') | Some('S') => 1,
None =>
return Err(anyhow::anyhow!(
"--expiry: missing suffix \
- (try: '{}y', '{}m', '{}w' or '{}d' instead)",
- digits, digits, digits, digits)),
+ (try: '{}y', '{}m', '{}w', '{}d' or '{}s' instead)",
+ digits, digits, digits, digits, digits)),
Some(suffix) =>
return Err(anyhow::anyhow!(
"--expiry: invalid suffix '{}' \
- (try: '{}y', '{}m', '{}w' or '{}d' instead)",
- suffix, digits, digits, digits, digits)),
+ (try: '{}y', '{}m', '{}w', '{}d' or '{}s' instead)",
+ suffix, digits, digits, digits, digits, digits)),
};
if !junk.is_empty() {
diff --git a/sq/src/sq_cli.rs b/sq/src/sq_cli.rs
index e46c1e0a..4016c65b 100644
--- a/sq/src/sq_cli.rs
+++ b/sq/src/sq_cli.rs
@@ -569,11 +569,11 @@ $ sq key generate --creation-time 20110609T1938+0200 --export noam.pgp
// Catch negative numbers.
.allow_hyphen_values(true)
.help("Makes the key expire after DURATION \
- (as N[ymwd]) [default: 3y]")
+ (as N[ymwds]) [default: 3y]")
.long_help(
"Makes the key expire after DURATION. \
- Either \"N[ymwd]\", for N years, months, \
- weeks, or days, or \"never\"."))
+ Either \"N[ymwds]\", for N years, months, \
+ weeks, days, seconds, or \"never\"."))
.group(ArgGroup::with_name("cap-sign")
.args(&["can-sign", "cannot-sign"]))
@@ -1122,11 +1122,11 @@ $ sq certify juliet.pgp romeo.pgp \"<romeo@example.org>\"
// Catch negative numbers.
.allow_hyphen_values(true)
.help("Makes the certification expire after DURATION \
- (as N[ymwd]) [default: 5y]")
+ (as N[ymwds]) [default: 5y]")
.long_help(
"Makes the certification expire after DURATION. \
- Either \"N[ymwd]\", for N years, months, \
- weeks, or days, or \"never\". [default: 5y]"))
+ Either \"N[ymwds]\", for N years, months, \
+ weeks, days, seconds, or \"never\". [default: 5y]"))
.arg(Arg::with_name("certifier")
.value_name("CERTIFIER-KEY")