From a9e2f0e250d923418fcabd866777298e151d11e6 Mon Sep 17 00:00:00 2001 From: Lucio Franco Date: Sat, 24 Aug 2019 12:18:24 -0700 Subject: [PATCH] work --- tonic-interop/Cargo.toml | 2 +- tonic-interop/src/bin/client.rs | 34 ++++++++++++++------------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/tonic-interop/Cargo.toml b/tonic-interop/Cargo.toml index f6d6b53..74f884f 100644 --- a/tonic-interop/Cargo.toml +++ b/tonic-interop/Cargo.toml @@ -23,7 +23,7 @@ http = "0.1" futures-util-preview = "=0.3.0-alpha.17" console = "0.7" -clap = "2.0" +structopt = "0.2" pretty_env_logger = "0.3" [build-dependencies] diff --git a/tonic-interop/src/bin/client.rs b/tonic-interop/src/bin/client.rs index 101e452..a3404ed 100644 --- a/tonic-interop/src/bin/client.rs +++ b/tonic-interop/src/bin/client.rs @@ -1,30 +1,24 @@ -use clap::{arg_enum, values_t, App, Arg}; use tonic_interop::client; +use structopt::{clap::arg_enum, StructOpt}; + +#[derive(StructOpt)] +struct Opts { + #[structopt( + long = "test_case", + use_delimiter = true, + min_values = 1, + raw(possible_values = r#"&Testcase::variants()"#) + )] + test_case: Vec +} #[tokio::main] async fn main() -> Result<(), Box> { pretty_env_logger::init(); - let matches = App::new("My Super Program") - .version("1.0") - .about("Does awesome things") - .arg( - Arg::with_name("test_case") - .long("test_case") - .value_name("TESTCASE") - .help( - "The name of the test case to execute. For example, - \"empty_unary\".", - ) - .possible_values(&Testcase::variants()) - .default_value("large_unary") - .takes_value(true) - .min_values(1) - .use_delimiter(true), - ) - .get_matches(); + let matches = Opts::from_args(); - let test_cases = values_t!(matches, "test_case", Testcase).unwrap_or_else(|e| e.exit()); + let test_cases = matches.test_case; let addr = "127.0.0.1:10000".parse()?;