You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.0 KiB
66 lines
2.0 KiB
//! Argument stuffs
|
|
use super::*;
|
|
|
|
|
|
mod error;
|
|
mod parse;
|
|
|
|
pub fn program_name() -> &'static str
|
|
{
|
|
lazy_static!{
|
|
static ref NAME: String = std::env::args().next().unwrap();
|
|
}
|
|
|
|
&NAME[..]
|
|
}
|
|
|
|
pub fn usage() -> !
|
|
{
|
|
println!(r#"signing encryptor version {pkg_version} (format version {real_version})
|
|
by {authour} with <3
|
|
licensed with GPL v3 or later
|
|
|
|
Usage: {program} [OPTIONS...] [-e|-d|-a] [-] [<files...>]
|
|
Usage: {program} --generate RSA [--input <old key>] [--password[=<password>]] [--format BIN|TEXT|PEM] <output> [<public part output>]
|
|
Usage: {program} --generate AES [--input <old key>] [--password[=<password>]] [--format BIN|TEXT] <output>
|
|
Usage: {program} --stat <key files...>
|
|
Usage: {program} --help
|
|
|
|
- Stop reading argument flags:
|
|
-e Encryption mode
|
|
-d Decryption mode
|
|
-a Autodetect mode (default)
|
|
OPTIONS:
|
|
-t <inp> <out> Process <input> to <output> (autodetect mode)
|
|
-te <inp> <out> Process <input> to <output> (encryption mode)
|
|
-td <inp> <out> Process <input> to <output> (decryption mode)
|
|
-i Process in-place for non-specific files (i.e. do not add or remove `.rae` file extension)
|
|
|
|
-k <key> Use this key (autodetect type)
|
|
-kR <key> Use this key (rsa private)
|
|
-kr <key> Use this key (rsa public)
|
|
-ka <key> Use this key (aes)
|
|
Other options for `-k`
|
|
-p Read a password from stdin for this key
|
|
-P <password> The next argument after the key file is a password for the key
|
|
-s This key is also a signing key
|
|
-S This key is only a signing key
|
|
|
|
EXAMPLE:
|
|
{program} -kRP key.rsa "super secret password" -ka key.aes -te input_file output_encrypted file
|
|
"#,
|
|
pkg_version = env!("CARGO_PKG_VERSION"),
|
|
real_version = CURRENT_VERSION,
|
|
authour = env!("CARGO_PKG_AUTHORS"),
|
|
program = program_name());
|
|
std::process::exit(1)
|
|
}
|
|
|
|
#[instrument]
|
|
/// Parse the program args into `Operation`.
|
|
pub async fn parse_args() -> Result<Spec, eyre::Report>
|
|
{
|
|
parse::parse(std::env::args().skip(1))
|
|
.with_suggestion(|| "Try passing `--help`")
|
|
}
|