update clap to 3.0

This commit is contained in:
Benjamin Fry 2022-01-16 09:01:28 -08:00
parent d7aa80fc30
commit f9861c9add
7 changed files with 58 additions and 32 deletions

36
Cargo.lock generated
View File

@ -314,11 +314,24 @@ dependencies = [
"atty",
"bitflags",
"strsim",
"textwrap",
"textwrap 0.11.0",
"unicode-width",
"vec_map",
]
[[package]]
name = "clap"
version = "3.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12e8611f9ae4e068fa3e56931fded356ff745e70987ff76924a6e0ab1c8ef2e3"
dependencies = [
"bitflags",
"indexmap",
"lazy_static",
"os_str_bytes",
"textwrap 0.14.2",
]
[[package]]
name = "concurrent-queue"
version = "1.2.2"
@ -976,6 +989,15 @@ dependencies = [
"vcpkg",
]
[[package]]
name = "os_str_bytes"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
dependencies = [
"memchr",
]
[[package]]
name = "parking"
version = "2.0.0"
@ -1391,7 +1413,7 @@ version = "0.3.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69b041cdcb67226aca307e6e7be44c8806423d83e018bd662360a93dabce4d71"
dependencies = [
"clap",
"clap 2.33.3",
"lazy_static",
"structopt-derive",
]
@ -1462,6 +1484,12 @@ dependencies = [
"unicode-width",
]
[[package]]
name = "textwrap"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80"
[[package]]
name = "thiserror"
version = "1.0.26"
@ -1622,7 +1650,7 @@ dependencies = [
name = "trust-dns"
version = "0.21.0-alpha.4"
dependencies = [
"clap",
"clap 3.0.7",
"env_logger",
"futures",
"log",
@ -1827,7 +1855,7 @@ dependencies = [
name = "trust-dns-util"
version = "0.21.0-alpha.4"
dependencies = [
"clap",
"clap 3.0.7",
"console",
"data-encoding",
"env_logger",

View File

@ -71,7 +71,7 @@ name = "named"
path = "src/named.rs"
[dependencies]
clap = "2.33"
clap = { version = "3.0", default-features = false, features = ["std", "cargo"] }
futures = { version = "0.3.5", default-features = false, features = ["std"] }
log = "0.4"
rustls = { version = "0.20", optional = true }

View File

@ -279,8 +279,8 @@ struct Args {
pub(crate) flag_https_port: Option<u16>,
}
impl<'a> From<ArgMatches<'a>> for Args {
fn from(matches: ArgMatches<'a>) -> Args {
impl<'a> From<ArgMatches> for Args {
fn from(matches: ArgMatches) -> Args {
Args {
flag_quiet: matches.is_present(QUIET_ARG),
flag_debug: matches.is_present(DEBUG_ARG),
@ -309,49 +309,49 @@ impl<'a> From<ArgMatches<'a>> for Args {
fn main() {
let args = app_from_crate!()
.arg(
Arg::with_name(QUIET_ARG)
Arg::new(QUIET_ARG)
.long(QUIET_ARG)
.short("q")
.short('q')
.help("Disable INFO messages, WARN and ERROR will remain")
.conflicts_with(DEBUG_ARG),
)
.arg(
Arg::with_name(DEBUG_ARG)
Arg::new(DEBUG_ARG)
.long(DEBUG_ARG)
.short("d")
.short('d')
.help("Turn on DEBUG messages (default is only INFO)")
.conflicts_with(QUIET_ARG),
)
.arg(
Arg::with_name(CONFIG_ARG)
Arg::new(CONFIG_ARG)
.long(CONFIG_ARG)
.short("c")
.short('c')
.help("Path to configuration file")
.value_name("FILE")
.default_value("/etc/named.toml"),
)
.arg(
Arg::with_name(ZONEDIR_ARG)
Arg::new(ZONEDIR_ARG)
.long(ZONEDIR_ARG)
.short("z")
.short('z')
.help("Path to the root directory for all zone files, see also config toml")
.value_name("DIR"),
)
.arg(
Arg::with_name(PORT_ARG)
Arg::new(PORT_ARG)
.long(PORT_ARG)
.short("p")
.short('p')
.help("Listening port for DNS queries, overrides any value in config file")
.value_name(PORT_ARG),
)
.arg(
Arg::with_name(TLS_PORT_ARG)
Arg::new(TLS_PORT_ARG)
.long(TLS_PORT_ARG)
.help("Listening port for DNS over TLS queries, overrides any value in config file")
.value_name(TLS_PORT_ARG),
)
.arg(
Arg::with_name(HTTPS_PORT_ARG)
Arg::new(HTTPS_PORT_ARG)
.long(HTTPS_PORT_ARG)
.help(
"Listening port for DNS over HTTPS queries, overrides any value in config file",

View File

@ -55,7 +55,7 @@ name = "resolve"
path = "src/resolve.rs"
[dependencies]
clap = "2.33.1"
clap = { version = "3.0", default-features = false, features = ["std", "cargo"] }
console = "0.15.0"
data-encoding = "2.2.0"
env_logger = { version = "0.9.0", features = ["termcolor", "humantime", "atty"] }

View File

@ -32,23 +32,23 @@ use openssl::rsa::Rsa;
use trust_dns_client::rr::dnssec::Algorithm;
fn args<'a>() -> ArgMatches<'a> {
fn args() -> ArgMatches {
App::new("Trust-DNS dnskey-to-pem")
.version(trust_dns_client::version())
.author("Benjamin Fry <benjaminfry@me.com>")
.about("Converts a dnskey, as generated from BIND's dnssec-keygen, into pem format")
.arg(
Arg::with_name("key")
Arg::new("key")
.value_name("PRIVATE_KEY_FILE")
.help("Input FILE from which to read the DNSSec private key")
.required(true)
.index(1),
)
.arg(
Arg::with_name("output")
Arg::new("output")
.value_name("OUTPUT_FILE")
.long("output")
.short("o")
.short('o')
.takes_value(true)
.help("Output FILE to write to")
.default_value("out.pem"),

View File

@ -24,9 +24,7 @@ use std::fs::OpenOptions;
use std::io::Write;
use std::path::PathBuf;
use clap::{
app_from_crate, crate_authors, crate_description, crate_name, crate_version, ArgMatches,
};
use clap::{app_from_crate, ArgMatches};
use trust_dns_client::rr::dnssec::Algorithm;
use trust_dns_proto::rr::dnssec::rdata::DNSSECRData;
@ -34,7 +32,7 @@ use trust_dns_proto::rr::record_data::RData;
use trust_dns_proto::rr::record_type::RecordType;
use trust_dns_resolver::Resolver;
fn args<'a>() -> ArgMatches<'a> {
fn args() -> ArgMatches {
app_from_crate!().bin_name("get-root-ksks").get_matches()
}

View File

@ -28,7 +28,7 @@ use openssl::pkey::PKey;
use trust_dns_client::rr::dnssec::{KeyPair, Public};
fn args<'a>() -> ArgMatches<'a> {
fn args() -> ArgMatches {
App::new("Trust-DNS pem-to-public-dnskey")
.version(trust_dns_client::version())
.author("Benjamin Fry <benjaminfry@me.com>")
@ -36,17 +36,17 @@ fn args<'a>() -> ArgMatches<'a> {
"Converts a PEM formatted public key into a raw public dnskey (not the inverse of dnskey-to-pem). This can be used to create a dnskey in the TrustAnchor internal format in Trust-DNS.",
)
.arg(
Arg::with_name("key")
Arg::new("key")
.value_name("PEM_KEY_FILE")
.help("Input PEM FILE from which to read the public key")
.required(true)
.index(1),
)
.arg(
Arg::with_name("output")
Arg::new("output")
.value_name("OUTPUT_FILE")
.long("output")
.short("o")
.short('o')
.takes_value(true)
.help("Output FILE to write to")
.default_value("out.dnskey"),