From de6eb649c9734f268cd3d9d0fb43694097b5c944 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 13 Dec 2022 19:27:51 +0000 Subject: [PATCH] dependencies: Switch to clap from structopt structopt's maintainers have deprecated it in favour of clap. Signed-off-by: Ian Jackson --- Cargo.lock | 115 +++++++++++++++++------------------------------ Cargo.toml | 2 +- client/client.rs | 8 ++-- server/server.rs | 14 +++--- src/config.rs | 6 +-- src/prelude.rs | 1 - src/reporter.rs | 6 +-- 7 files changed, 59 insertions(+), 93 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ad6f58c..021dcd9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -26,15 +26,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - [[package]] name = "atty" version = "0.2.14" @@ -108,17 +99,41 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "2.34.0" +version = "3.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" dependencies = [ - "ansi_term", "atty", "bitflags", + "clap_derive", + "clap_lex", + "indexmap", + "once_cell", "strsim", + "termcolor", "textwrap", - "unicode-width", - "vec_map", +] + +[[package]] +name = "clap_derive" +version = "3.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", ] [[package]] @@ -422,15 +437,6 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -[[package]] -name = "heck" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "heck" version = "0.4.0" @@ -452,6 +458,7 @@ version = "1.0.0" dependencies = [ "backtrace", "base64", + "clap", "educe", "either", "env_logger", @@ -459,7 +466,7 @@ dependencies = [ "eyre", "fehler", "futures", - "heck 0.4.0", + "heck", "hippotat-macros", "hyper", "hyper-tls", @@ -477,7 +484,6 @@ dependencies = [ "pin-project-lite", "regex", "sha2", - "structopt", "subtle", "syslog", "thiserror", @@ -872,6 +878,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "os_str_bytes" +version = "6.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" + [[package]] name = "parking_lot" version = "0.12.1" @@ -1097,33 +1109,9 @@ dependencies = [ [[package]] name = "strsim" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - -[[package]] -name = "structopt" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" -dependencies = [ - "clap", - "lazy_static", - "structopt-derive", -] - -[[package]] -name = "structopt-derive" -version = "0.4.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" -dependencies = [ - "heck 0.3.3", - "proc-macro-error", - "proc-macro2", - "quote", - "syn", -] +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "subtle" @@ -1180,12 +1168,9 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.11.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] +checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" @@ -1318,30 +1303,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" -[[package]] -name = "unicode-segmentation" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" - -[[package]] -name = "unicode-width" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" - [[package]] name = "vcpkg" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version_check" version = "0.9.4" diff --git a/Cargo.toml b/Cargo.toml index ac9e104..2f76e6f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,7 @@ hippotat-macros = { version = "1.0.0", path = "macros" } # (or currently available): backtrace = "0.3" base64 = "0.13" +clap = { version = "3", features = ["derive"] } educe = "0.4" either = "1" env_logger = "0.9" @@ -50,7 +51,6 @@ memchr = "2" nix = "0.25" pin-project-lite = "0.2" sha2 = "0.10" -structopt = "0.3" subtle = "2" syslog = "6" tokio = { version = "1", features = ["full"] } diff --git a/client/client.rs b/client/client.rs index 17dee6b..5a58c42 100644 --- a/client/client.rs +++ b/client/client.rs @@ -5,12 +5,12 @@ use hippotat::prelude::*; use hippotat_macros::into_crlfs; -#[derive(StructOpt,Debug)] +#[derive(clap::Parser,Debug)] pub struct Opts { - #[structopt(flatten)] + #[clap(flatten)] log: LogOpts, - #[structopt(flatten)] + #[clap(flatten)] config: config::Opts, } @@ -315,7 +315,7 @@ async fn run_client( #[tokio::main] async fn main() { - let opts = Opts::from_args(); + let opts = ::parse(); let (ics,) = config::startup("hippotat", LinkEnd::Client, &opts.config, &opts.log, |ics|Ok((ics,))); diff --git a/server/server.rs b/server/server.rs index b30e2da..590f16f 100644 --- a/server/server.rs +++ b/server/server.rs @@ -13,24 +13,24 @@ pub use daemon::Daemoniser; pub use sweb::{WebRequest, WebResponse, WebResponseBody}; pub use suser::User; -#[derive(StructOpt,Debug)] +#[derive(clap::Parser,Debug)] pub struct Opts { - #[structopt(flatten)] + #[clap(flatten)] pub log: LogOpts, - #[structopt(flatten)] + #[clap(flatten)] pub config: config::Opts, /// Daemonise - #[structopt(long)] + #[clap(long)] daemon: bool, /// Write our pid to this file - #[structopt(long)] + #[clap(long)] pidfile: Option, /// Print a config item, do not actually run - #[structopt(long)] + #[clap(long)] print_config: Option, } @@ -130,7 +130,7 @@ pub async fn route_packet(global: &Global, } fn main() { - let opts = Opts::from_args(); + let opts = ::parse(); let daemon = if opts.daemon && opts.print_config.is_none() { Some(Daemoniser::phase1()) diff --git a/src/config.rs b/src/config.rs index a668c06..1c8cc94 100644 --- a/src/config.rs +++ b/src/config.rs @@ -75,18 +75,18 @@ http_timeout = 121 target_requests_outstanding = 10 "#; -#[derive(StructOpt,Debug)] +#[derive(clap::Args,Debug)] pub struct Opts { /// Top-level config file or directory /// /// Look for `main.cfg`, `config.d` and `secrets.d` here. /// /// Or if this is a file, just read that file. - #[structopt(long, default_value="/etc/hippotat")] + #[clap(long, default_value="/etc/hippotat")] pub config: PathBuf, /// Additional config files or dirs, which can override the others - #[structopt(long, multiple=true, number_of_values=1)] + #[clap(long, multiple=true, number_of_values=1)] pub extra_config: Vec, } diff --git a/src/prelude.rs b/src/prelude.rs index 805442f..68326df 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -40,7 +40,6 @@ pub use lazy_static::lazy_static; pub use log::{trace, debug, info, warn, error}; pub use memchr::memmem; pub use pin_project_lite::pin_project; -pub use structopt::StructOpt; pub use subtle::ConstantTimeEq; pub use thiserror::Error; pub use tokio::io::{AsyncBufReadExt, AsyncWriteExt}; diff --git a/src/reporter.rs b/src/reporter.rs index 692e3ed..dc8a575 100644 --- a/src/reporter.rs +++ b/src/reporter.rs @@ -4,7 +4,7 @@ use crate::prelude::*; -#[derive(StructOpt,Debug)] +#[derive(clap::Parser,Debug)] pub struct LogOpts { /// Increase debug level /// @@ -15,11 +15,11 @@ pub struct LogOpts { /// and two -`D` means to send to syslog even messages from lower layers /// (normally just the hippotat modules log to /// syslog). - #[structopt(long, short="D", parse(from_occurrences))] + #[clap(long, short='D', parse(from_occurrences))] debug: usize, /// Syslog facility to use - #[structopt(long, parse(try_from_str=parse_syslog_facility))] + #[clap(long, parse(try_from_str=parse_syslog_facility))] syslog_facility: Option, } -- 2.30.2