From 2a93c1d327b4a6771126a6fb9887bd4d7e5aa0c5 Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: Sat, 18 Jan 2025 18:57:50 +0100 Subject: [PATCH] examples: port from structopt to clap/derive --- Cargo.toml | 2 +- examples/dd_test.rs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c30d05e..ed26eca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,5 +25,5 @@ env_logger = "0.10.0" [dev-dependencies] rayon = "1.8.0" -structopt = "0.3.26" +clap = { version = "4", features = ["derive"] } byte-unit = "4.0.19" diff --git a/examples/dd_test.rs b/examples/dd_test.rs index 63fcea3..2415836 100644 --- a/examples/dd_test.rs +++ b/examples/dd_test.rs @@ -18,18 +18,18 @@ use byte_unit::Byte; use cmd_lib::*; use rayon::prelude::*; use std::time::Instant; -use structopt::StructOpt; +use clap::Parser; const DATA_SIZE: u64 = 10 * 1024 * 1024 * 1024; // 10GB data -#[derive(StructOpt)] -#[structopt(name = "dd_test", about = "Get disk read bandwidth.")] +#[derive(Parser)] +#[clap(name = "dd_test", about = "Get disk read bandwidth.")] struct Opt { - #[structopt(short, default_value = "4096")] + #[clap(short, default_value = "4096")] block_size: u64, - #[structopt(short, default_value = "1")] + #[clap(short, default_value = "1")] thread_num: u64, - #[structopt(short)] + #[clap(short)] file: String, } @@ -39,7 +39,7 @@ fn main() -> CmdResult { block_size, thread_num, file, - } = Opt::from_args(); + } = Opt::parse(); run_cmd! ( info "Dropping caches at first";