chore(interop): Change structopt to clap (#882)

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