mirror of
https://github.com/str4d/rage.git
synced 2025-04-04 19:37:51 +03:00
Migrate to clap 4
for generating completions
This commit is contained in:
parent
c1e4e0aa93
commit
e4666b9d9b
3 changed files with 63 additions and 69 deletions
55
Cargo.lock
generated
55
Cargo.lock
generated
|
@ -167,6 +167,12 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anstyle"
|
||||||
|
version = "1.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arc-swap"
|
name = "arc-swap"
|
||||||
version = "1.6.0"
|
version = "1.6.0"
|
||||||
|
@ -413,42 +419,43 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
|
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"textwrap 0.11.0",
|
"textwrap",
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "3.2.25"
|
version = "4.3.19"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123"
|
checksum = "5fd304a20bff958a57f04c4e96a2e7594cc4490a0e809cbd48bb6437edaa452d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atty",
|
"clap_builder",
|
||||||
"bitflags 1.3.2",
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_builder"
|
||||||
|
version = "4.3.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "01c6a3f08f1fe5662a35cfe393aec09c4df95f60ee93b7556505260f75eee9e1"
|
||||||
|
dependencies = [
|
||||||
|
"anstyle",
|
||||||
"clap_lex",
|
"clap_lex",
|
||||||
"indexmap 1.9.3",
|
|
||||||
"strsim",
|
|
||||||
"termcolor",
|
|
||||||
"textwrap 0.16.0",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_complete"
|
name = "clap_complete"
|
||||||
version = "3.2.5"
|
version = "4.3.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3f7a2e0a962c45ce25afce14220bc24f9dade0a1787f185cecf96bfba7847cd8"
|
checksum = "5fc443334c81a804575546c5a8a79b4913b50e28d69232903604cada1de817ce"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap 3.2.25",
|
"clap 4.3.19",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_lex"
|
name = "clap_lex"
|
||||||
version = "0.2.4"
|
version = "0.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
|
checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b"
|
||||||
dependencies = [
|
|
||||||
"os_str_bytes",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "console"
|
name = "console"
|
||||||
|
@ -1629,12 +1636,6 @@ version = "0.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "os_str_bytes"
|
|
||||||
version = "6.5.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "page_size"
|
name = "page_size"
|
||||||
version = "0.4.2"
|
version = "0.4.2"
|
||||||
|
@ -1938,7 +1939,7 @@ version = "0.9.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"age",
|
"age",
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap 3.2.25",
|
"clap 4.3.19",
|
||||||
"clap_complete",
|
"clap_complete",
|
||||||
"console",
|
"console",
|
||||||
"ctrlc",
|
"ctrlc",
|
||||||
|
@ -2529,12 +2530,6 @@ dependencies = [
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "textwrap"
|
|
||||||
version = "0.16.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.44"
|
version = "1.0.44"
|
||||||
|
|
|
@ -76,8 +76,8 @@ time = { version = ">=0.3.7, <0.3.24", optional = true } # time 0.3.24 has MSRV
|
||||||
zip = { version = "0.6.2", optional = true }
|
zip = { version = "0.6.2", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
clap = "3.1"
|
clap = { version = "4", default-features = false }
|
||||||
clap_complete = "3.1"
|
clap_complete = "4"
|
||||||
flate2 = "1"
|
flate2 = "1"
|
||||||
man = "0.3"
|
man = "0.3"
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use clap::{Arg, Command};
|
use clap::{Arg, ArgAction, Command};
|
||||||
use clap_complete::{generate, shells, Generator};
|
use clap_complete::{generate, shells, Generator};
|
||||||
use std::fs::{create_dir_all, File};
|
use std::fs::{create_dir_all, File};
|
||||||
|
|
||||||
|
@ -46,53 +46,57 @@ fn generate_completions(mut app: Command, bin_name: &str) {
|
||||||
fn rage_completions() {
|
fn rage_completions() {
|
||||||
let app = Command::new("rage")
|
let app = Command::new("rage")
|
||||||
.arg(Arg::new("input"))
|
.arg(Arg::new("input"))
|
||||||
.arg(Arg::new("encrypt").short('e').long("encrypt"))
|
|
||||||
.arg(Arg::new("decrypt").short('d').long("decrypt"))
|
|
||||||
.arg(Arg::new("passphrase").short('p').long("passphrase"))
|
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("max-work-factor")
|
Arg::new("encrypt")
|
||||||
.takes_value(true)
|
.short('e')
|
||||||
.long("max-work-factor"),
|
.long("encrypt")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("decrypt")
|
||||||
|
.short('d')
|
||||||
|
.long("decrypt")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("passphrase")
|
||||||
|
.short('p')
|
||||||
|
.long("passphrase")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
|
)
|
||||||
|
.arg(Arg::new("max-work-factor").long("max-work-factor"))
|
||||||
|
.arg(
|
||||||
|
Arg::new("armor")
|
||||||
|
.short('a')
|
||||||
|
.long("armor")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(Arg::new("armor").short('a').long("armor"))
|
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("recipient")
|
Arg::new("recipient")
|
||||||
.takes_value(true)
|
|
||||||
.multiple_occurrences(true)
|
|
||||||
.short('r')
|
.short('r')
|
||||||
.long("recipient"),
|
.long("recipient")
|
||||||
|
.action(ArgAction::Append),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("recipients-file")
|
Arg::new("recipients-file")
|
||||||
.takes_value(true)
|
|
||||||
.multiple_occurrences(true)
|
|
||||||
.short('R')
|
.short('R')
|
||||||
.long("recipients-file"),
|
.long("recipients-file")
|
||||||
|
.action(ArgAction::Append),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("identity")
|
Arg::new("identity")
|
||||||
.takes_value(true)
|
|
||||||
.multiple_occurrences(true)
|
|
||||||
.short('i')
|
.short('i')
|
||||||
.long("identity"),
|
.long("identity")
|
||||||
|
.action(ArgAction::Append),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(Arg::new("plugin-name").short('j'))
|
||||||
Arg::new("output")
|
.arg(Arg::new("output").short('o').long("output"));
|
||||||
.takes_value(true)
|
|
||||||
.short('o')
|
|
||||||
.long("output"),
|
|
||||||
);
|
|
||||||
|
|
||||||
generate_completions(app, "rage");
|
generate_completions(app, "rage");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rage_keygen_completions() {
|
fn rage_keygen_completions() {
|
||||||
let app = Command::new("rage-keygen").arg(
|
let app = Command::new("rage-keygen").arg(Arg::new("output").short('o').long("output"));
|
||||||
Arg::new("output")
|
|
||||||
.takes_value(true)
|
|
||||||
.short('o')
|
|
||||||
.long("output"),
|
|
||||||
);
|
|
||||||
|
|
||||||
generate_completions(app, "rage-keygen");
|
generate_completions(app, "rage-keygen");
|
||||||
}
|
}
|
||||||
|
@ -102,17 +106,12 @@ fn rage_mount_completions() {
|
||||||
.arg(Arg::new("filename"))
|
.arg(Arg::new("filename"))
|
||||||
.arg(Arg::new("mountpoint"))
|
.arg(Arg::new("mountpoint"))
|
||||||
.arg(Arg::new("types").short('t').long("types"))
|
.arg(Arg::new("types").short('t').long("types"))
|
||||||
.arg(
|
.arg(Arg::new("max-work-factor").long("max-work-factor"))
|
||||||
Arg::new("max-work-factor")
|
|
||||||
.takes_value(true)
|
|
||||||
.long("max-work-factor"),
|
|
||||||
)
|
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("identity")
|
Arg::new("identity")
|
||||||
.takes_value(true)
|
|
||||||
.multiple_occurrences(true)
|
|
||||||
.short('i')
|
.short('i')
|
||||||
.long("identity"),
|
.long("identity")
|
||||||
|
.action(ArgAction::Append),
|
||||||
);
|
);
|
||||||
|
|
||||||
generate_completions(app, "rage-mount");
|
generate_completions(app, "rage-mount");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue