chiark / gitweb /
dependencies: Switch to clap from structopt
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 13 Dec 2022 19:27:51 +0000 (19:27 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 14 Dec 2022 21:52:29 +0000 (21:52 +0000)
structopt's maintainers have deprecated it in favour of clap.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Cargo.lock
Cargo.toml
client/client.rs
server/server.rs
src/config.rs
src/prelude.rs
src/reporter.rs

index ad6f58c1cae9be8f66d3b8b4b47cc681dff461aa..021dcd9a9aa1ee2e7454056c7e39a510afd09e9c 100644 (file)
@@ -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"
index ac9e10439136530e358a13ff2616ecbe0adf90f3..2f76e6fd823c624002c382cb71a15faab7920c6b 100644 (file)
@@ -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"] }
index 17dee6b77249204e825815aed98594191e297290..5a58c4222e1db341122a0ec7c8c74f65137718d8 100644 (file)
@@ -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<C:HCC>(
 
 #[tokio::main]
 async fn main() {
-  let opts = Opts::from_args();
+  let opts = <Opts as clap::Parser>::parse();
   let (ics,) = config::startup("hippotat", LinkEnd::Client,
                                &opts.config, &opts.log, |ics|Ok((ics,)));
 
index b30e2da49d19dff29faf78649f9a6156fa581e81..590f16f57e49e3f218d17da5e822374045a410aa 100644 (file)
@@ -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<String>,
 
   /// Print a config item, do not actually run
-  #[structopt(long)]
+  #[clap(long)]
   print_config: Option<String>,
 }
 
@@ -130,7 +130,7 @@ pub async fn route_packet(global: &Global,
 }
 
 fn main() {
-  let opts = Opts::from_args();
+  let opts = <Opts as clap::Parser>::parse();
 
   let daemon = if opts.daemon && opts.print_config.is_none() {
     Some(Daemoniser::phase1())
index a668c06c83598c9bfef1af529c7cd155e56c96cd..1c8cc94b86d14556bb6f1ba39f267f5053a9fa41 100644 (file)
@@ -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<PathBuf>,
 }
 
index 805442fec8dc6c199634399110c097282dda3730..68326df096a832ccd2812069186227a6ecac6dd4 100644 (file)
@@ -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};
index 692e3edbf1fba27826a5b6a31dc20c3465d06b9b..dc8a575dd25ebb6916f75b9bbb410630c87379c8 100644 (file)
@@ -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<syslog::Facility>,
 }