From ef4f2a04a4f9bc78e488046e5d47a0deb05c273f Mon Sep 17 00:00:00 2001 From: Maarten de Vries Date: Wed, 20 Apr 2022 16:34:55 +0200 Subject: [PATCH] Switch to clap v3 for examples. --- CHANGELOG | 1 + Cargo.toml | 2 +- examples/tcp-client.rs | 11 ++++------- examples/tcp-server.rs | 11 ++++------- examples/unix-seqpacket-client.rs | 9 +++------ examples/unix-seqpacket-server.rs | 9 +++------ examples/unix-stream-client.rs | 9 +++------ examples/unix-stream-server.rs | 9 +++------ 8 files changed, 22 insertions(+), 39 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d8883aa..21f0de1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ # Unreleased - [fix][minor] Fix unintended infinite recursion in generic trait implementations. +- [change][patch] Switch to `clap` v3 in the examples. # Version 0.5.0-alpha8 - 2022-01-25 - [rename][major] Rename `crate::util::format` module to `crate::format`. diff --git a/Cargo.toml b/Cargo.toml index 072dcf9..9eaa93a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,9 +33,9 @@ fizyr-rpc-macros = { version = "=0.5.0-alpha8", path = "macros", optional = true [dev-dependencies] assert2 = "0.3.3" +clap = { version = "3.1.10", features = ["derive"] } tokio = { version = "1.0.0", features = ["macros"] } fizyr-rpc = { path = ".", features = ["unix-seqpacket", "unix-stream", "tcp"] } -structopt = "0.3.18" memfile = "0.2.0" [package.metadata.docs.rs] diff --git a/examples/tcp-client.rs b/examples/tcp-client.rs index 654fe12..a522f4f 100644 --- a/examples/tcp-client.rs +++ b/examples/tcp-client.rs @@ -1,18 +1,15 @@ use fizyr_rpc::TcpPeer; -use structopt::StructOpt; -#[derive(StructOpt)] -#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] -#[structopt(setting = structopt::clap::AppSettings::UnifiedHelpMessage)] -#[structopt(setting = structopt::clap::AppSettings::DeriveDisplayOrder)] +#[derive(clap::Parser)] +#[clap(setting = clap::AppSettings::DeriveDisplayOrder)] struct Options { - #[structopt(default_value = "localhost:12345")] + #[clap(default_value = "localhost:12345")] address: String, } #[tokio::main(flavor = "current_thread")] async fn main() { - if let Err(e) = do_main(&Options::from_args()).await { + if let Err(e) = do_main(&clap::Parser::parse()).await { eprintln!("Error: {}", e); std::process::exit(1); } diff --git a/examples/tcp-server.rs b/examples/tcp-server.rs index 18c04b6..6c0418f 100644 --- a/examples/tcp-server.rs +++ b/examples/tcp-server.rs @@ -1,18 +1,15 @@ use fizyr_rpc::TcpListener; -use structopt::StructOpt; -#[derive(StructOpt)] -#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] -#[structopt(setting = structopt::clap::AppSettings::UnifiedHelpMessage)] -#[structopt(setting = structopt::clap::AppSettings::DeriveDisplayOrder)] +#[derive(clap::Parser)] +#[clap(setting = clap::AppSettings::DeriveDisplayOrder)] struct Options { - #[structopt(default_value = "[::]:12345")] + #[clap(default_value = "[::]:12345")] bind: String, } #[tokio::main(flavor = "current_thread")] async fn main() { - if let Err(e) = do_main(&Options::from_args()).await { + if let Err(e) = do_main(&clap::Parser::parse()).await { eprintln!("Error: {}", e); std::process::exit(1); } diff --git a/examples/unix-seqpacket-client.rs b/examples/unix-seqpacket-client.rs index 9828922..d67c397 100644 --- a/examples/unix-seqpacket-client.rs +++ b/examples/unix-seqpacket-client.rs @@ -1,19 +1,16 @@ use fizyr_rpc::UnixSeqpacketPeer; use std::path::PathBuf; -use structopt::StructOpt; -#[derive(StructOpt)] -#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] -#[structopt(setting = structopt::clap::AppSettings::UnifiedHelpMessage)] -#[structopt(setting = structopt::clap::AppSettings::DeriveDisplayOrder)] +#[derive(clap::Parser)] +#[clap(setting = clap::AppSettings::DeriveDisplayOrder)] struct Options { socket: PathBuf, } #[tokio::main(flavor = "current_thread")] async fn main() { - if let Err(e) = do_main(&Options::from_args()).await { + if let Err(e) = do_main(&clap::Parser::parse()).await { eprintln!("Error: {}", e); std::process::exit(1); } diff --git a/examples/unix-seqpacket-server.rs b/examples/unix-seqpacket-server.rs index 51f2cd6..35f66b5 100644 --- a/examples/unix-seqpacket-server.rs +++ b/examples/unix-seqpacket-server.rs @@ -1,18 +1,15 @@ use fizyr_rpc::UnixSeqpacketListener; use std::path::PathBuf; -use structopt::StructOpt; -#[derive(StructOpt)] -#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] -#[structopt(setting = structopt::clap::AppSettings::UnifiedHelpMessage)] -#[structopt(setting = structopt::clap::AppSettings::DeriveDisplayOrder)] +#[derive(clap::Parser)] +#[clap(setting = clap::AppSettings::DeriveDisplayOrder)] struct Options { socket: PathBuf, } #[tokio::main(flavor = "current_thread")] async fn main() { - if let Err(e) = do_main(&Options::from_args()).await { + if let Err(e) = do_main(&clap::Parser::parse()).await { eprintln!("Error: {}", e); std::process::exit(1); } diff --git a/examples/unix-stream-client.rs b/examples/unix-stream-client.rs index f3d69e3..565f381 100644 --- a/examples/unix-stream-client.rs +++ b/examples/unix-stream-client.rs @@ -1,19 +1,16 @@ use fizyr_rpc::UnixStreamPeer; use std::path::PathBuf; -use structopt::StructOpt; -#[derive(StructOpt)] -#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] -#[structopt(setting = structopt::clap::AppSettings::UnifiedHelpMessage)] -#[structopt(setting = structopt::clap::AppSettings::DeriveDisplayOrder)] +#[derive(clap::Parser)] +#[clap(setting = clap::AppSettings::DeriveDisplayOrder)] struct Options { socket: PathBuf, } #[tokio::main(flavor = "current_thread")] async fn main() { - if let Err(e) = do_main(&Options::from_args()).await { + if let Err(e) = do_main(&clap::Parser::parse()).await { eprintln!("Error: {}", e); std::process::exit(1); } diff --git a/examples/unix-stream-server.rs b/examples/unix-stream-server.rs index 3e8dc54..9873984 100644 --- a/examples/unix-stream-server.rs +++ b/examples/unix-stream-server.rs @@ -1,18 +1,15 @@ use fizyr_rpc::UnixStreamListener; use std::path::PathBuf; -use structopt::StructOpt; -#[derive(StructOpt)] -#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] -#[structopt(setting = structopt::clap::AppSettings::UnifiedHelpMessage)] -#[structopt(setting = structopt::clap::AppSettings::DeriveDisplayOrder)] +#[derive(clap::Parser)] +#[clap(setting = clap::AppSettings::DeriveDisplayOrder)] struct Options { socket: PathBuf, } #[tokio::main(flavor = "current_thread")] async fn main() { - if let Err(e) = do_main(&Options::from_args()).await { + if let Err(e) = do_main(&clap::Parser::parse()).await { eprintln!("Error: {}", e); std::process::exit(1); }