/// 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 version = Box::leak(
format!("{} (sequoia-openpgp {})",
env!("CARGO_PKG_VERSION"),
sequoia_openpgp::VERSION)
.into_boxed_str()) as &str;
let app = app
.version(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("Overwrites existing files"))
.arg(Arg::with_name("known-notation")
.long("known-notation").value_name("NOTATION")
.multiple(true).number_of_values(1)
.help("Adds NOTATION to the list of known notations")
.long_help("Adds NOTATION to the list of known notations. \
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 a message")
.arg(Arg::with_name("input")
.value_name("FILE")
.help("Reads from FILE or stdin if omitted"))
.arg(Arg::with_name("output")
.short("o").long("output").value_name("FILE")
.help("Writes to FILE or stdout if omitted"))
.arg(Arg::with_name("signatures")
.short("n").long("signatures").value_name("N")
.default_value("0")
.help("Sets the threshold of valid signatures to N")
.long_help(
"Sets the threshold of valid signatures to N. \
If this threshold is not reached, the message \
will not be considered verified."))
.arg(Arg::with_name("sender-cert-file")
.long("signer-cert").value_name("CERT")
.multiple(true).number_of_values(1)
.help("Verifies signatures with CERT"))
.arg(Arg::with_name("secret-key-file")
.long("recipient-key").value_name("KEY")
.multiple(true).number_of_values(1)
.help("Decrypts with KEY"))
.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("Prints a packet dump to stderr"))
.arg(Arg::with_name("hex")
.short("x").long("hex")
.help("Prints 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("Reads from FILE or stdin if omitted"))
.arg(Arg::with_name("output")
.short("o").long