@@ -18,7 +18,7 @@ use {{{externCrateName}}}::{Api, ApiNoContext, Claims, Client, ContextWrapperExt
18
18
{ {/apis} }
19
19
{ {/apiInfo} }
20
20
};
21
- use clap::{ App , Arg} ;
21
+ use clap::{ Command , Arg} ;
22
22
23
23
// NOTE: Set environment variable RUST_LOG to the name of the executable (or "cargo run") to activate console logging for all loglevels.
24
24
// See https://docs.rs/env_logger/latest/env_logger/ for more details
@@ -41,10 +41,10 @@ use client_auth::build_token;
41
41
fn main() {
42
42
env_logger::init();
43
43
44
- let matches = App ::new(" client" )
45
- .arg(Arg::with_name (" operation" )
44
+ let matches = Command ::new(" client" )
45
+ .arg(Arg::new (" operation" )
46
46
.help(" Sets the operation to run" )
47
- .possible_values(& [
47
+ .value_parser( [
48
48
{{#apiInfo} }
49
49
{ {#apis} }
50
50
{ {#operations} }
@@ -61,17 +61,15 @@ fn main() {
61
61
])
62
62
.required(true)
63
63
.index(1))
64
- .arg(Arg::with_name ("https")
64
+ .arg(Arg::new ("https")
65
65
.long("https")
66
66
.help("Whether to use HTTPS or not"))
67
- .arg(Arg::with_name ("host")
67
+ .arg(Arg::new ("host")
68
68
.long("host")
69
- .takes_value(true)
70
69
.default_value("{ {{serverHost} }}")
71
70
.help("Hostname to contact"))
72
- .arg(Arg::with_name ("port")
71
+ .arg(Arg::new ("port")
73
72
.long("port")
74
- .takes_value(true)
75
73
.default_value("{ {{serverPort} }}")
76
74
.help("Port to contact"))
77
75
.get_matches();
@@ -106,22 +104,22 @@ fn main() {
106
104
b"secret").unwrap();
107
105
108
106
let auth_data = if !auth_token.is_empty() {
109
- Some(AuthData::Bearer(swagger::auth::Bearer { token: auth_token} ))
107
+ Some(AuthData::Bearer(auth_token))
110
108
} else {
111
109
// No Bearer-token available, so return None
112
110
None
113
111
} ;
114
112
115
- let is_https = matches.is_present ("https");
113
+ let is_https = matches.contains_id ("https");
116
114
let base_url = format!("{ } ://{ } :{ } ",
117
115
if is_https { " https" } else { " http" } ,
118
- matches.value_of ("host").unwrap(),
119
- matches.value_of ("port").unwrap());
116
+ matches.get_one::< String > ("host").unwrap(),
117
+ matches.get_one::< u16 > ("port").unwrap());
120
118
121
119
let context: ClientContext =
122
120
swagger::make_context!(ContextBuilder, EmptyContext, auth_data, XSpanIdString::default());
123
121
124
- let mut client : Box<dyn ApiNoContext <ClientContext >> = if matches.is_present("https") {
122
+ let mut client : Box<dyn ApiNoContext <ClientContext >> = if is_https {
125
123
// Using Simple HTTPS
126
124
let client = Box::new(Client::try_new_https(&base_url)
127
125
.expect(" Failed to create HTTPS client" ));
@@ -141,7 +139,7 @@ fn main() {
141
139
rt.spawn(server::create("127.0.0.1:8081", false));
142
140
{ {/hasCallbacks} }
143
141
144
- match matches.value_of ("operation") {
142
+ match matches.get_one::< String > ("operation") {
145
143
{{#apiInfo} }
146
144
{ {#apis} }
147
145
{ {#operations} }
0 commit comments