summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2021-01-20 09:47:57 +0100
committerJustus Winter <justus@sequoia-pgp.org>2021-01-20 11:37:22 +0100
commit7e8aea4f2f62c4366111da1fe82df513a3ec9566 (patch)
tree384ce37244b4986c264c582f2528ce73b7fb8420
parent0f4a78e138afa04821e8502aa0cae1ded8f2c8ea (diff)
sq: Reformat cli definitions.
- Bring some consistency, make it easier to navigate and add subcommands later.
-rw-r--r--sq/src/sq_cli.rs437
1 files changed, 204 insertions, 233 deletions
diff --git a/sq/src/sq_cli.rs b/sq/src/sq_cli.rs
index 6036b0c6..a5ec85ec 100644
--- a/sq/src/sq_cli.rs
+++ b/sq/src/sq_cli.rs
@@ -12,45 +12,38 @@ pub fn configure(app: App<'static, 'static>) -> App<'static, 'static> {
.about("Sequoia is an implementation of OpenPGP. This is a command-line frontend.")
.setting(AppSettings::SubcommandRequiredElseHelp)
.arg(Arg::with_name("force")
- .long("force")
- .short("f")
+ .short("f").long("force")
.help("Overwrite existing files"))
.arg(Arg::with_name("known-notation")
- .long("known-notation")
- .multiple(true)
- .value_name("NOTATION")
- .number_of_values(1)
+ .long("known-notation").value_name("NOTATION")
+ .multiple(true).number_of_values(1)
.help("The notation name is considered known. \
This is used when validating signatures. \
Signatures that have unknown notations with the \
critical bit set are considered invalid."))
+
.subcommand(SubCommand::with_name("decrypt")
.display_order(10)
.about("Decrypts an OpenPGP message")
- .arg(Arg::with_name("input").value_name("FILE")
+ .arg(Arg::with_name("input")
+ .value_name("FILE")
.help("Sets the input file to use"))
- .arg(Arg::with_name("output").value_name("FILE")
- .long("output")
- .short("o")
+ .arg(Arg::with_name("output")
+ .short("o").long("output").value_name("FILE")
.help("Sets the output file to use"))
.arg(Arg::with_name("signatures").value_name("N")
.help("The number of valid signatures required. \
Default: 0")
- .long("signatures")
- .short("n"))
+ .short("n").long("signatures"))
.arg(Arg::with_name("sender-cert-file")
- .long("signer-cert")
- .multiple(true)
- .value_name("CERT")
- .number_of_values(1)
- .help("The signer's certificate to verify signatures \
+ .long("signer-cert").value_name("CERT")
+ .multiple(true).number_of_values(1)
+ .help("The sender's certificate to verify signatures \
with, given as a file \
(can be given multiple times)"))
.arg(Arg::with_name("secret-key-file")
- .long("recipient-key")
- .multiple(true)
- .value_name("KEY")
- .number_of_values(1)
+ .long("recipient-key").value_name("KEY")
+ .multiple(true).number_of_values(1)
.help("Secret key to decrypt with, given as a file \
(can be given multiple times)"))
.arg(Arg::with_name("dump-session-key")
@@ -60,44 +53,39 @@ pub fn configure(app: App<'static, 'static>) -> App<'static, 'static> {
.long("dump")
.help("Print a packet dump to stderr"))
.arg(Arg::with_name("hex")
- .long("hex")
- .short("x")
- .help("Print a hexdump (implies --dump)")))
+ .short("x").long("hex")
+ .help("Print a hexdump (implies --dump)"))
+ )
+
.subcommand(SubCommand::with_name("encrypt")
.display_order(20)
.about("Encrypts a message")
- .arg(Arg::with_name("input").value_name("FILE")
+ .arg(Arg::with_name("input")
+ .value_name("FILE")
.help("Sets the input file to use"))
- .arg(Arg::with_name("output").value_name("FILE")
- .long("output")
- .short("o")
+ .arg(Arg::with_name("output")
+ .short("o").long("output").value_name("FILE")
.help("Sets the output file to use"))
.arg(Arg::with_name("binary")
- .long("binary")
- .short("B")
+ .short("B").long("binary")
.help("Don't ASCII-armor encode the OpenPGP data"))
.arg(Arg::with_name("recipients-cert-file")
- .long("recipient-cert")
- .multiple(true)
- .value_name("CERT-RING")
- .number_of_values(1)
+ .long("recipient-cert").value_name("CERT-RING")
+ .multiple(true).number_of_values(1)
.help("Recipients to encrypt for, given as a file \
(can be given multiple times)"))
.arg(Arg::with_name("signer-key-file")
- .long("signer-key")
- .multiple(true)
- .value_name("KEY")
- .number_of_values(1)
+ .long("signer-key").value_name("KEY")
+ .multiple(true).number_of_values(1)
.help("Secret key to sign with, given as a file \
(can be given multiple times)"))
.arg(Arg::with_name("symmetric")
- .long("symmetric")
- .short("s")
+ .short("s").long("symmetric")
.multiple(true)
.help("Encrypt with a password \
(can be given multiple times)"))
- .arg(Arg::with_name("mode").value_name("MODE")
- .long("mode")
+ .arg(Arg::with_name("mode")
+ .long("mode").value_name("MODE")
.possible_values(&["transport", "rest", "all"])
.default_value("all")
.help("Selects what kind of keys are considered for \
@@ -107,15 +95,13 @@ pub fn configure(app: App<'static, 'static>) -> App<'static, 'static> {
and all selects all encryption-capable \
subkeys"))
.arg(Arg::with_name("compression")
- .value_name("KIND")
- .long("compression")
+ .long("compression").value_name("KIND")
.possible_values(&["none", "pad", "zip", "zlib",
"bzip2"])
.default_value("pad")
.help("Selects compression scheme to use"))
- .arg(Arg::with_name("time").value_name("TIME")
- .long("time")
- .short("t")
+ .arg(Arg::with_name("time")
+ .short("t").long("time").value_name("TIME")
.help("Chooses keys valid at the specified time and \
sets the signature's creation time"))
.arg(Arg::with_name("use-expired-subkey")
@@ -128,125 +114,123 @@ pub fn configure(app: App<'static, 'static>) -> App<'static, 'static> {
.subcommand(SubCommand::with_name("merge-signatures")
.display_order(31)
.about("Merges two signatures")
- .arg(Arg::with_name("input1").value_name("FILE")
+ .arg(Arg::with_name("input1")
+ .value_name("FILE")
.help("Sets the first input file to use"))
- .arg(Arg::with_name("input2").value_name("FILE")
+ .arg(Arg::with_name("input2")
+ .value_name("FILE")
.help("Sets the second input file to use"))
- .arg(Arg::with_name("output").value_name("FILE")
- .long("output")
- .short("o")
+ .arg(Arg::with_name("output")
+ .short("o").long("output").value_name("FILE")
.help("Sets the output file to use"))
)
.subcommand(SubCommand::with_name("sign")
.display_order(25)
.about("Signs a message")
- .arg(Arg::with_name("input").value_name("FILE")
+ .arg(Arg::with_name("input")
+ .value_name("FILE")
.help("Sets the input file to use"))
- .arg(Arg::with_name("output").value_name("FILE")
- .long("output")
- .short("o")
+ .arg(Arg::with_name("output")
+ .short("o").long("output").value_name("FILE")
.help("Sets the output file to use"))
.arg(Arg::with_name("binary")
- .long("binary")
- .short("B")
+ .short("B").long("binary")
.help("Don't ASCII-armor encode the OpenPGP data"))
.arg(Arg::with_name("detached")
.long("detached")
.help("Create a detached signature"))
.arg(Arg::with_name("append")
- .long("append")
- .short("a")
+ .short("a").long("append")
.conflicts_with("notarize")
.help("Append signature to existing signature"))
.arg(Arg::with_name("notarize")
- .long("notarize")
- .short("n")
+ .short("n").long("notarize")
.conflicts_with("append")
.help("Signs a message and all existing signatures"))
.arg(Arg::with_name("secret-key-file")
- .long("signer-key")
- .multiple(true)
- .value_name("KEY")
- .number_of_values(1)
+ .long("signer-key").value_name("KEY")
+ .multiple(true).number_of_values(1)
.help("Secret key to sign with, given as a file \
(can be given multiple times)"))
- .arg(Arg::with_name("time").value_name("TIME")
- .long("time")
- .short("t")
+ .arg(Arg::with_name("time")
+ .short("t").long("time").value_name("TIME")
.help("Chooses keys valid at the specified time and \
- sets the signature's creation time")))
+ sets the signature's creation time"))
+ )
+
.subcommand(SubCommand::with_name("verify")
.display_order(26)
.about("Verifies a message")
- .arg(Arg::with_name("input").value_name("FILE")
+ .arg(Arg::with_name("input")
+ .value_name("FILE")
.help("Sets the input file to use"))
- .arg(Arg::with_name("output").value_name("FILE")
- .long("output")
- .short("o")
+ .arg(Arg::with_name("output")
+ .short("o").long("output").value_name("FILE")
.help("Sets the output file to use"))
.arg(Arg::with_name("detached")
- .long("detached")
- .value_name("SIG")
+ .long("detached").value_name("SIG")
.help("Verifies a detached signature"))
- .arg(Arg::with_name("signatures").value_name("N")
+ .arg(Arg::with_name("signatures")
+ .short("n").long("signatures").value_name("N")
.help("The number of valid signatures required. \
- Default: 0")
- .long("signatures")
- .short("n"))
+ Default: 0"))
.arg(Arg::with_name("sender-cert-file")
- .long("signer-cert")
- .multiple(true)
- .value_name("CERT")
- .number_of_values(1)
- .help("The signer's certificate to verify signatures \
+ .long("signer-cert").value_name("CERT")
+ .multiple(true).number_of_values(1)
+ .help("The sender's certificate to verify signatures \
with, given as a file \
- (can be given multiple times)")))
+ (can be given multiple times)"))
+ )
+
.subcommand(SubCommand::with_name("enarmor")
.about("Applies ASCII Armor to a file")
- .arg(Arg::with_name("input").value_name("FILE")
+ .arg(Arg::with_name("input")
+ .value_name("FILE")
.help("Sets the input file to use"))
- .arg(Arg::with_name("output").value_name("FILE")
- .long("output")
- .short("o")
+ .arg(Arg::with_name("output")
+ .short("o").long("output").value_name("FILE")
.help("Sets the output file to use"))
.arg(Arg::with_name("kind")
- .value_name("KIND")
- .long("kind")
+ .long("kind").value_name("KIND")
.possible_values(&["message", "publickey", "secretkey",
"signature", "file"])
.default_value("file")
- .help("Selects the kind of header line to produce")))
+ .help("Selects the kind of header line to produce"))
+ )
.subcommand(SubCommand::with_name("dearmor")
.about("Removes ASCII Armor from a file")
- .arg(Arg::with_name("input").value_name("FILE")
+ .arg(Arg::with_name("input")
+ .value_name("FILE")
.help("Sets the input file to use"))
- .arg(Arg::with_name("output").value_name("FILE")
- .long("output")
- .short("o")
- .help("Sets the output file to use")))
+ .arg(Arg::with_name("output")
+ .short("o").long("output").value_name("FILE")
+ .help("Sets the output file to use"))
+ )
+
.subcommand(SubCommand::with_name("autocrypt")
.about("Autocrypt support")
.setting(AppSettings::SubcommandRequiredElseHelp)
.subcommand(SubCommand::with_name("decode")
.about("Converts Autocrypt-encoded keys to \
OpenPGP Certificates")
- .arg(Arg::with_name("input").value_name("FILE")
+ .arg(Arg::with_name("input")
+ .value_name("FILE")
.help("Sets the input file to use"))
- .arg(Arg::with_name("output").value_name("FILE")
- .long("output")
- .short("o")
- .help("Sets the output file to use")))
+ .arg(Arg::with_name("output")
+ .short("o").long("output").value_name("FILE")
+ .help("Sets the output file to use"))
+ )
.subcommand(SubCommand::with_name("encode-sender")
.about("Encodes the sender's OpenPGP \
Certificates into \
an Autocrypt header")
- .arg(Arg::with_name("input").value_name("FILE")
+ .arg(Arg::with_name("input")
+ .value_name("FILE")
.help("Sets the input file to use"))
- .arg(Arg::with_name("output").value_name("FILE")
- .long("output")
- .short("o")
+ .arg(Arg::with_name("output")
+ .short("o").long("output").value_name("FILE")
.help("Sets the output file to use"))
.arg(Arg::with_name("address")
.long("address")
@@ -259,14 +243,19 @@ pub fn configure(app: App<'static, 'static>) -> App<'static, 'static> {
"mutual"])
.default_value("nopreference")
.help("Sets the prefer-encrypt \
- attribute"))))
+ attribute"))
+ )
+ )
+
.subcommand(SubCommand::with_name("inspect")
.about("Inspects a sequence of OpenPGP packets")
- .arg(Arg::with_name("input").value_name("FILE")
+ .arg(Arg::with_name("input")
+ .value_name("FILE")
.help("Sets the input file to use"))
.arg(Arg::with_name("certifications")
.long("certifications")
- .help("Print third-party certifications")))
+ .help("Print third-party certifications"))
+ )
.subcommand(
SubCommand::with_name("key")
@@ -276,17 +265,12 @@ pub fn configure(app: App<'static, 'static>) -> App<'static, 'static> {
SubCommand::with_name("generate")
.about("Generates a new key")
.arg(Arg::with_name("userid")
- .value_name("EMAIL")
- .long("userid")
- .short("u")
- .multiple(true)
- .number_of_values(1)
+ .short("u").long("userid").value_name("EMAIL")
+ .multiple(true).number_of_values(1)
.help("Add userid to the key \
(can be given multiple times)"))
.arg(Arg::with_name("cipher-suite")
- .value_name("CIPHER-SUITE")
- .long("cipher-suite")
- .short("c")
+ .short("c").long("cipher-suite").value_name("CIPHER-SUITE")
.possible_values(&["rsa3k", "rsa4k", "cv25519"])
.default_value("cv25519")
.help("Cryptographic algorithms used for the key."))
@@ -299,13 +283,11 @@ pub fn configure(app: App<'static, 'static>) -> App<'static, 'static> {
.args(&["expires", "expires-in"]))
.arg(Arg::with_name("expires")
- .value_name("TIME")
- .long("expires")
+ .long("expires").value_name("TIME")
.help("Absolute time When the key should expire, \
or 'never'."))
.arg(Arg::with_name("expires-in")
- .value_name("DURATION")
- .long("expires-in")
+ .long("expires-in").value_name("DURATION")
// Catch negative numbers.
.allow_hyphen_values(true)
.help("Relative time when the key should expire. \
@@ -324,8 +306,8 @@ pub fn configure(app: App<'static, 'static>) -> App<'static, 'static> {
.group(ArgGroup::with_name("cap-encrypt")
.args(&["can-encrypt", "cannot-encrypt"]))
- .arg(Arg::with_name("can-encrypt").value_name("PURPOSE")
- .long("can-encrypt")
+ .arg(Arg::with_name("can-encrypt")
+ .long("can-encrypt").value_name("PURPOSE")
.possible_values(&["transport", "storage",
"universal"])
.help("The key has an encryption-capable subkey \
@@ -334,35 +316,29 @@ pub fn configure(app: App<'static, 'static>) -> App<'static, 'static> {
.long("cannot-encrypt")
.help("The key will not be able to encrypt data"))
- .arg(Arg::with_name("export").value_name("OUTFILE")
- .long("export")
- .short("e")
+ .arg(Arg::with_name("export")
+ .short("e").long("export").value_name("OUTFILE")
.help("Exports the key instead of saving it in \
the store")
.required(true))
- .arg(Arg::with_name("rev-cert").value_name("FILE or -")
- .long("rev-cert")
+ .arg(Arg::with_name("rev-cert")
+ .long("rev-cert").value_name("FILE or -")
.required_if("export", "-")
.help("Sets the output file for the revocation \
certificate. Default is <OUTFILE>.rev, \
- mandatory if OUTFILE is '-'.")))
+ mandatory if OUTFILE is '-'."))
+ )
.subcommand(
SubCommand::with_name("adopt")
.about("Bind keys from one certificate to another.")
.arg(Arg::with_name("keyring")
- .value_name("KEYRING")
- .long("keyring")
- .short("r")
- .multiple(true)
- .number_of_values(1)
+ .short("r").long("keyring").value_name("KEYRING")
+ .multiple(true).number_of_values(1)
.help("A keyring containing the keys specified \
in --key."))
.arg(Arg::with_name("key")
- .value_name("KEY")
- .long("key")
- .short("k")
- .multiple(true)
- .number_of_values(1)
+ .short("k").long("key").value_name("KEY")
+ .multiple(true).number_of_values(1)
.required(true)
.help("Adds the specified key or subkey to the \
certificate."))
@@ -375,7 +351,6 @@ pub fn configure(app: App<'static, 'static>) -> App<'static, 'static> {
.required(true)
.help("The certificate to add keys to."))
)
-
.subcommand(
SubCommand::with_name("attest-certifications")
.about("Attests third-party certifications allowing \
@@ -394,6 +369,7 @@ pub fn configure(app: App<'static, 'static>) -> App<'static, 'static> {
.help("Change attestations on this key."))
)
)
+
.subcommand(
SubCommand::with_name("certring")
.about("Manipulates certificate rings")
@@ -407,144 +383,138 @@ pub fn configure(app: App<'static, 'static>) -> App<'static, 'static> {
of the predicates match. To require all \
predicates to match, chain multiple \
invocations of this command.")
- .arg(Arg::with_name("input").value_name("FILE")
+ .arg(Arg::with_name("input")
+ .value_name("FILE")
.multiple(true)
.help("Sets the input files to use"))
- .arg(Arg::with_name("output").value_name("FILE")
- .long("output")
- .short("o")
+ .arg(Arg::with_name("output")
+ .short("o").long("output").value_name("FILE")
.help("Sets the output file to use"))
- .arg(Arg::with_name("name").value_name("NAME")
- .long("name")
- .multiple(true)
- .number_of_values(1)
+ .arg(Arg::with_name("name")
+ .long("name").value_name("NAME")
+ .multiple(true).number_of_values(1)
.help("Match on this name"))
- .arg(Arg::with_name("email").value_name("ADDRESS")
- .long("email")
- .multiple(true)
- .number_of_values(1)
+ .arg(Arg::with_name("email")
+ .long("email").value_name("ADDRESS")
+ .multiple(true).number_of_values(1)
.help("Match on this email address"))
- .arg(Arg::with_name("domain").value_name("FQDN")
- .long("domain")
- .multiple(true)
- .number_of_values(1)
+ .arg(Arg::with_name("domain")
+ .long("domain").value_name("FQDN")
+ .multiple(true).number_of_values(1)
.help("Match on this email domain name"))
.arg(Arg::with_name("prune-certs")
- .long("prune-certs")
- .short("P")
+ .short("P").long("prune-certs")
.help("Remove certificate components not matching \
the filter"))
.arg(Arg::with_name("binary")
- .long("binary")
- .short("B")
- .help("Don't ASCII-armor the certring")))
+ .short("B").long("binary")
+ .help("Don't ASCII-armor the certring"))
+ )
.subcommand(
SubCommand::with_name("join")
.about("Joins certs into a certring")
- .arg(Arg::with_name("input").value_name("FILE")
+ .arg(Arg::with_name("input")
+ .value_name("FILE")
.multiple(true)
.help("Sets the input files to use"))
- .arg(Arg::with_name("output").value_name("FILE")
- .long("output")
- .short("o")
+ .arg(Arg::with_name("output")
+ .short("o").long("output").value_name("FILE")
.help("Sets the output file to use"))
.arg(Arg::with_name("binary")
- .long("binary")
- .short("B")
- .help("Don't ASCII-armor the certring")))
+ .short("B").long("binary")
+ .help("Don't ASCII-armor the certring"))
+ )
.subcommand(
SubCommand::with_name("list")
.about("Lists certs in a certring")
- .arg(Arg::with_name("input").value_name("FILE")
- .help("Sets the input file to use")))
+ .arg(Arg::with_name("input")
+ .value_name("FILE")
+ .help("Sets the input file to use"))
+ )
.subcommand(
SubCommand::with_name("split")
.about("Splits a certring into individual certs")
- .arg(Arg::with_name("input").value_name("FILE")
+ .arg(Arg::with_name("input")
+ .value_name("FILE")
.help("Sets the input file to use"))
- .arg(Arg::with_name("prefix").value_name("FILE")
- .long("prefix")
- .short("p")
+ .arg(Arg::with_name("prefix")
+ .short("p").long("prefix").value_name("FILE")
.help("Sets the prefix to use for output files \
(defaults to the input filename with a \
dash, or 'output' if certring is read \
- from stdin)"))))
+ from stdin)")))
+ )
.subcommand(SubCommand::with_name("packet")
.about("OpenPGP Packet manipulation")
.setting(AppSettings::SubcommandRequiredElseHelp)
.subcommand(SubCommand::with_name("dump")
.about("Lists OpenPGP packets")
- .arg(Arg::with_name("input").value_name("FILE")
+ .arg(Arg::with_name("input")
+ .value_name("FILE")
.help("Sets the input file to use"))
- .arg(Arg::with_name("output").value_name("FILE")
- .long("output")
- .short("o")
+ .arg(Arg::with_name("output")
+ .short("o").long("output").value_name("FILE")
.help("Sets the output file to use"))
.arg(Arg::with_name("session-key")
- .long("session-key")
- .value_name("SESSION-KEY")
+ .long("session-key").value_name("SESSION-KEY")
.help("Session key to decrypt encryption \
containers"))
.arg(Arg::with_name("mpis")
.long("mpis")
.help("Print MPIs"))
.arg(Arg::with_name("hex")
- .long("hex")
- .short("x")
- .help("Print a hexdump")))
-
+ .short("x").long("hex")
+ .help("Print a hexdump"))
+ )
.subcommand(SubCommand::with_name("decrypt")
.display_order(10)
.about("Decrypts an OpenPGP message, dumping \
the content of the encryption \
container without further processing")
- .arg(Arg::with_name("input").value_name("FILE")
+ .arg(Arg::with_name("input")
+ .value_name("FILE")
.help("Sets the input file to use"))