/// Command-line parser for sq.
use clap::{App, Arg, ArgGroup, SubCommand, AppSettings};
pub fn build() -> App<'static, 'static> {
configure(App::new("sq"))
}
/// Defines the CLI.
///
/// The order of top-level subcommands is:
///
/// - Encryption & decryption (1xx)
/// - Signing & verification (2xx)
/// - Key & cert-ring management (3xx)
/// - Key discovery & networking (4xx)
/// - Armor (5xx)
/// - Inspection & packet manipulation (6xx)
pub fn configure(app: App<'static, 'static>) -> App<'static, 'static> {
let app = app
.version(env!("CARGO_PKG_VERSION"))
.about("Sequoia is an implementation of OpenPGP. This is a command-line frontend.")
.settings(&[
AppSettings::SubcommandRequiredElseHelp,
AppSettings::VersionlessSubcommands,
])
.arg(Arg::with_name("force")
.short("f").long("force")
.help("Overwrite existing files"))
.arg(Arg::with_name("known-notation")
.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(110)
.about("Decrypts an OpenPGP message")
.arg(Arg::with_name("input")
.value_name("FILE")
.help("Sets the input file to use"))
.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")
.short("n").long("signatures"))
.arg(Arg::with_name("sender-cert-file")
.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").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")
.long("dump-session-key")
.help("Prints the session key to stderr"))
.arg(Arg::with_name("dump")
.long("dump")
.help("Print a packet dump to stderr"))
.arg(Arg::with_name("hex")
.short("x").long("hex")
.help("Print a hexdump (implies --dump)"))
)
.subcommand(SubCommand::with_name("encrypt")
.display_order(100)
.about("Encrypts a message")
.arg(Arg::with_name("input")
.value_name("FILE")
.help("Sets the input file to use"))
.arg(Arg::with_name("output")
.short("o").long("output").value_name("FILE")
.help("Sets the output file to use"))
.arg(Arg::with_name("binary")
.short("B").long("binary")
.help("Don't ASCII-armor encode the OpenPGP data"))
.arg(Arg::with_name("recipients-cert-file")
.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").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")
.short("s").long("symmetric")
.multiple(true)
.help("Encrypt with a password \