chore(interop): Change structopt to clap (#882)
This commit is contained in:
+1
-1
@@ -17,6 +17,7 @@ path = "src/bin/server.rs"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
async-stream = "0.3"
|
async-stream = "0.3"
|
||||||
bytes = "1.0"
|
bytes = "1.0"
|
||||||
|
clap = {version = "3", features = ["derive"]}
|
||||||
console = "0.14"
|
console = "0.14"
|
||||||
futures-core = "0.3"
|
futures-core = "0.3"
|
||||||
futures-util = "0.3"
|
futures-util = "0.3"
|
||||||
@@ -25,7 +26,6 @@ http-body = "0.4.2"
|
|||||||
hyper = "0.14"
|
hyper = "0.14"
|
||||||
prost = "0.9"
|
prost = "0.9"
|
||||||
prost-derive = "0.9"
|
prost-derive = "0.9"
|
||||||
structopt = "0.3"
|
|
||||||
tokio = {version = "1.0", features = ["rt-multi-thread", "time", "macros", "fs"]}
|
tokio = {version = "1.0", features = ["rt-multi-thread", "time", "macros", "fs"]}
|
||||||
tokio-stream = "0.1"
|
tokio-stream = "0.1"
|
||||||
tonic = {path = "../tonic", features = ["tls"]}
|
tonic = {path = "../tonic", features = ["tls"]}
|
||||||
|
|||||||
+33
-39
@@ -1,20 +1,15 @@
|
|||||||
|
use clap::Parser;
|
||||||
use interop::client;
|
use interop::client;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use structopt::{clap::arg_enum, StructOpt};
|
|
||||||
use tonic::transport::Endpoint;
|
use tonic::transport::Endpoint;
|
||||||
use tonic::transport::{Certificate, ClientTlsConfig};
|
use tonic::transport::{Certificate, ClientTlsConfig};
|
||||||
|
|
||||||
#[derive(StructOpt)]
|
#[derive(Parser)]
|
||||||
struct Opts {
|
struct Opts {
|
||||||
#[structopt(name = "use_tls", long)]
|
#[clap(name = "use_tls", long)]
|
||||||
use_tls: bool,
|
use_tls: bool,
|
||||||
|
|
||||||
#[structopt(
|
#[clap(long = "test_case", use_delimiter = true, min_values = 1, arg_enum)]
|
||||||
long = "test_case",
|
|
||||||
use_delimiter = true,
|
|
||||||
min_values = 1,
|
|
||||||
possible_values = &Testcase::variants()
|
|
||||||
)]
|
|
||||||
test_case: Vec<Testcase>,
|
test_case: Vec<Testcase>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,7 +17,7 @@ struct Opts {
|
|||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
interop::trace_init();
|
interop::trace_init();
|
||||||
|
|
||||||
let matches = Opts::from_args();
|
let matches = Opts::parse();
|
||||||
|
|
||||||
let test_cases = matches.test_case;
|
let test_cases = matches.test_case;
|
||||||
|
|
||||||
@@ -98,33 +93,32 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
arg_enum! {
|
#[derive(Debug, Copy, Clone, clap::ArgEnum)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[clap(rename_all = "verbatim")]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
enum Testcase {
|
enum Testcase {
|
||||||
empty_unary,
|
empty_unary,
|
||||||
cacheable_unary,
|
cacheable_unary,
|
||||||
large_unary,
|
large_unary,
|
||||||
client_compressed_unary,
|
client_compressed_unary,
|
||||||
server_compressed_unary,
|
server_compressed_unary,
|
||||||
client_streaming,
|
client_streaming,
|
||||||
client_compressed_streaming,
|
client_compressed_streaming,
|
||||||
server_streaming,
|
server_streaming,
|
||||||
server_compressed_streaming,
|
server_compressed_streaming,
|
||||||
ping_pong,
|
ping_pong,
|
||||||
empty_stream,
|
empty_stream,
|
||||||
compute_engine_creds,
|
compute_engine_creds,
|
||||||
jwt_token_creds,
|
jwt_token_creds,
|
||||||
oauth2_auth_token,
|
oauth2_auth_token,
|
||||||
per_rpc_creds,
|
per_rpc_creds,
|
||||||
custom_metadata,
|
custom_metadata,
|
||||||
status_code_and_message,
|
status_code_and_message,
|
||||||
special_status_message,
|
special_status_message,
|
||||||
unimplemented_method,
|
unimplemented_method,
|
||||||
unimplemented_service,
|
unimplemented_service,
|
||||||
cancel_after_begin,
|
cancel_after_begin,
|
||||||
cancel_after_first_response,
|
cancel_after_first_response,
|
||||||
timeout_on_sleeping_server,
|
timeout_on_sleeping_server,
|
||||||
concurrent_large_unary
|
concurrent_large_unary,
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
|
use clap::Parser;
|
||||||
use interop::server;
|
use interop::server;
|
||||||
use structopt::StructOpt;
|
|
||||||
use tonic::transport::Server;
|
use tonic::transport::Server;
|
||||||
use tonic::transport::{Identity, ServerTlsConfig};
|
use tonic::transport::{Identity, ServerTlsConfig};
|
||||||
|
|
||||||
#[derive(StructOpt)]
|
#[derive(Parser)]
|
||||||
struct Opts {
|
struct Opts {
|
||||||
#[structopt(name = "use_tls", long)]
|
#[clap(name = "use_tls", long)]
|
||||||
use_tls: bool,
|
use_tls: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ struct Opts {
|
|||||||
async fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
|
||||||
interop::trace_init();
|
interop::trace_init();
|
||||||
|
|
||||||
let matches = Opts::from_args();
|
let matches = Opts::parse();
|
||||||
|
|
||||||
let addr = "127.0.0.1:10000".parse().unwrap();
|
let addr = "127.0.0.1:10000".parse().unwrap();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user