mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-02-13 21:19:05 +01:00
fix(all): update all code to latest version
* add new APIs * remove old ones * add latest json files
This commit is contained in:
@@ -93,10 +93,10 @@ impl FieldCursor {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError)
|
||||
pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool)
|
||||
-> (&'a str, Option<&'a str>) {
|
||||
let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string()));
|
||||
match kv.rfind('=') {
|
||||
let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap));
|
||||
match kv.find('=') {
|
||||
None => {
|
||||
add_err();
|
||||
return (kv, None)
|
||||
@@ -171,25 +171,52 @@ impl JsonTokenStorage {
|
||||
}
|
||||
|
||||
impl TokenStorage for JsonTokenStorage {
|
||||
// NOTE: logging might be interesting, currently we swallow all errors
|
||||
fn set(&mut self, scope_hash: u64, token: Option<Token>) {
|
||||
let json_token = json::encode(&token).unwrap();
|
||||
let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash));
|
||||
if let Ok(mut f) = res {
|
||||
f.write(json_token.as_bytes()).ok();
|
||||
}
|
||||
}
|
||||
type Error = io::Error;
|
||||
|
||||
fn get(&self, scope_hash: u64) -> Option<Token> {
|
||||
if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) {
|
||||
let mut json_string = String::new();
|
||||
if let Ok(_) = f.read_to_string(&mut json_string) {
|
||||
if let Ok(token) = json::decode::<Token>(&json_string) {
|
||||
return Some(token)
|
||||
// NOTE: logging might be interesting, currently we swallow all errors
|
||||
fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> {
|
||||
match token {
|
||||
None => {
|
||||
match fs::remove_file(self.path(scope_hash)) {
|
||||
Err(err) =>
|
||||
match err.kind() {
|
||||
io::ErrorKind::NotFound => None,
|
||||
_ => Some(err)
|
||||
},
|
||||
Ok(_) => None
|
||||
}
|
||||
}
|
||||
Some(token) => {
|
||||
let json_token = json::encode(&token).unwrap();
|
||||
match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) {
|
||||
Ok(mut f) => {
|
||||
match f.write(json_token.as_bytes()) {
|
||||
Ok(_) => None,
|
||||
Err(io_err) => Some(io_err),
|
||||
}
|
||||
},
|
||||
Err(io_err) => Some(io_err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> {
|
||||
match fs::File::open(&self.path(scope_hash)) {
|
||||
Ok(mut f) => {
|
||||
let mut json_string = String::new();
|
||||
match f.read_to_string(&mut json_string) {
|
||||
Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())),
|
||||
Err(io_err) => Err(io_err),
|
||||
}
|
||||
},
|
||||
Err(io_err) => {
|
||||
match io_err.kind() {
|
||||
io::ErrorKind::NotFound => Ok(None),
|
||||
_ => Err(io_err)
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,7 +313,7 @@ pub enum CLIError {
|
||||
Configuration(ConfigurationError),
|
||||
ParseError((&'static str, &'static str, String, String)),
|
||||
UnknownParameter(String),
|
||||
InvalidKeyValueSyntax(String),
|
||||
InvalidKeyValueSyntax(String, bool),
|
||||
Input(InputError),
|
||||
Field(FieldError),
|
||||
}
|
||||
@@ -302,9 +329,10 @@ impl fmt::Display for CLIError {
|
||||
arg_name, value, type_name, err_desc),
|
||||
CLIError::UnknownParameter(ref param_name)
|
||||
=> writeln!(f, "Parameter '{}' is unknown.", param_name),
|
||||
CLIError::InvalidKeyValueSyntax(ref kv)
|
||||
=> writeln!(f, "'{}' does not match pattern <key>=<value>", kv),
|
||||
|
||||
CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => {
|
||||
let hashmap_info = if is_hashmap { "hashmap " } else { "" };
|
||||
writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> {
|
||||
Ok(expanded_config_dir)
|
||||
}
|
||||
|
||||
pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> {
|
||||
pub fn application_secret_from_directory(dir: &str,
|
||||
secret_basename: &str,
|
||||
json_app_secret: &str)
|
||||
-> Result<ApplicationSecret, CLIError> {
|
||||
let secret_path = Path::new(dir).join(secret_basename);
|
||||
let secret_str = || secret_path.as_path().to_str().unwrap().to_string();
|
||||
let secret_io_error = |io_err: io::Error| {
|
||||
@@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re
|
||||
Err(mut err) => {
|
||||
if err.kind() == io::ErrorKind::NotFound {
|
||||
// Write our built-in one - user may adjust the written file at will
|
||||
let secret = ApplicationSecret {
|
||||
client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(),
|
||||
client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(),
|
||||
token_uri: "https://accounts.google.com/o/oauth2/token".to_string(),
|
||||
auth_uri: Default::default(),
|
||||
redirect_uris: Default::default(),
|
||||
client_email: None,
|
||||
auth_provider_x509_cert_url: None,
|
||||
client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string())
|
||||
};
|
||||
|
||||
let app_secret = ConsoleApplicationSecret {
|
||||
installed: Some(secret),
|
||||
web: None,
|
||||
};
|
||||
|
||||
let json_enocded_secret = json::encode(&app_secret).unwrap();
|
||||
err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) {
|
||||
Err(cfe) => cfe,
|
||||
Ok(mut f) => {
|
||||
match f.write(json_enocded_secret.as_bytes()) {
|
||||
match f.write(json_app_secret.as_bytes()) {
|
||||
Err(io_err) => io_err,
|
||||
Ok(_) => continue,
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
extern crate docopt;
|
||||
extern crate yup_oauth2 as oauth2;
|
||||
extern crate yup_hyper_mock as mock;
|
||||
extern crate rustc_serialize;
|
||||
extern crate serde;
|
||||
extern crate hyper;
|
||||
@@ -38,6 +39,12 @@ Configuration:
|
||||
A directory into which we will store our persistent data. Defaults to a user-writable
|
||||
directory that we will create during the first invocation.
|
||||
[default: ~/.google-service-cli]
|
||||
--debug
|
||||
Output all server communication to standard error. `tx` and `rx` are placed into
|
||||
the same stream.
|
||||
--debug-auth
|
||||
Output all communication related to authentication to standard error. `tx` and `rx` are placed into
|
||||
the same stream.
|
||||
");
|
||||
|
||||
mod cmn;
|
||||
@@ -61,7 +68,7 @@ impl Engine {
|
||||
-> Option<api::Error> {
|
||||
let mut call = self.hub.web_resource().delete(&self.opt.arg_id);
|
||||
for parg in self.opt.arg_v.iter() {
|
||||
let (key, value) = parse_kv_arg(&*parg, err);
|
||||
let (key, value) = parse_kv_arg(&*parg, err, false);
|
||||
match key {
|
||||
"alt"
|
||||
|"fields"
|
||||
@@ -92,7 +99,6 @@ impl Engine {
|
||||
} {
|
||||
Err(api_err) => Some(api_err),
|
||||
Ok(mut response) => {
|
||||
println!("DEBUG: REMOVE ME {:?}", response);
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -103,7 +109,7 @@ impl Engine {
|
||||
-> Option<api::Error> {
|
||||
let mut call = self.hub.web_resource().get(&self.opt.arg_id);
|
||||
for parg in self.opt.arg_v.iter() {
|
||||
let (key, value) = parse_kv_arg(&*parg, err);
|
||||
let (key, value) = parse_kv_arg(&*parg, err, false);
|
||||
match key {
|
||||
"alt"
|
||||
|"fields"
|
||||
@@ -135,8 +141,7 @@ impl Engine {
|
||||
} {
|
||||
Err(api_err) => Some(api_err),
|
||||
Ok((mut response, output_schema)) => {
|
||||
println!("DEBUG: REMOVE ME {:?}", response);
|
||||
serde::json::to_writer(&mut ostream, &output_schema).unwrap();
|
||||
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -145,10 +150,10 @@ impl Engine {
|
||||
|
||||
fn _web_resource_get_token(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Option<api::Error> {
|
||||
let mut request: api::SiteVerificationWebResourceGettokenRequest = Default::default();
|
||||
let mut request = api::SiteVerificationWebResourceGettokenRequest::default();
|
||||
let mut call = self.hub.web_resource().get_token(&request);
|
||||
for parg in self.opt.arg_v.iter() {
|
||||
let (key, value) = parse_kv_arg(&*parg, err);
|
||||
let (key, value) = parse_kv_arg(&*parg, err, false);
|
||||
match key {
|
||||
"alt"
|
||||
|"fields"
|
||||
@@ -168,9 +173,10 @@ impl Engine {
|
||||
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
||||
}
|
||||
}
|
||||
let mut field_name: FieldCursor = Default::default();
|
||||
|
||||
let mut field_name = FieldCursor::default();
|
||||
for kvarg in self.opt.arg_kv.iter() {
|
||||
let (key, value) = parse_kv_arg(&*kvarg, err);
|
||||
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
||||
if let Err(field_err) = field_name.set(&*key) {
|
||||
err.issues.push(field_err);
|
||||
}
|
||||
@@ -186,11 +192,11 @@ impl Engine {
|
||||
},
|
||||
"site.identifier" => {
|
||||
request_site_init(&mut request);
|
||||
request.site.as_mut().unwrap().identifier = value.unwrap_or("").to_string();
|
||||
request.site.as_mut().unwrap().identifier = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
"site.type" => {
|
||||
request_site_init(&mut request);
|
||||
request.site.as_mut().unwrap().type_ = value.unwrap_or("").to_string();
|
||||
request.site.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
_ => {
|
||||
err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string())));
|
||||
@@ -209,8 +215,7 @@ impl Engine {
|
||||
} {
|
||||
Err(api_err) => Some(api_err),
|
||||
Ok((mut response, output_schema)) => {
|
||||
println!("DEBUG: REMOVE ME {:?}", response);
|
||||
serde::json::to_writer(&mut ostream, &output_schema).unwrap();
|
||||
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -219,10 +224,10 @@ impl Engine {
|
||||
|
||||
fn _web_resource_insert(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Option<api::Error> {
|
||||
let mut request: api::SiteVerificationWebResourceResource = Default::default();
|
||||
let mut request = api::SiteVerificationWebResourceResource::default();
|
||||
let mut call = self.hub.web_resource().insert(&request, &self.opt.arg_verification_method);
|
||||
for parg in self.opt.arg_v.iter() {
|
||||
let (key, value) = parse_kv_arg(&*parg, err);
|
||||
let (key, value) = parse_kv_arg(&*parg, err, false);
|
||||
match key {
|
||||
"alt"
|
||||
|"fields"
|
||||
@@ -242,9 +247,10 @@ impl Engine {
|
||||
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
||||
}
|
||||
}
|
||||
let mut field_name: FieldCursor = Default::default();
|
||||
|
||||
let mut field_name = FieldCursor::default();
|
||||
for kvarg in self.opt.arg_kv.iter() {
|
||||
let (key, value) = parse_kv_arg(&*kvarg, err);
|
||||
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
||||
if let Err(field_err) = field_name.set(&*key) {
|
||||
err.issues.push(field_err);
|
||||
}
|
||||
@@ -257,20 +263,20 @@ impl Engine {
|
||||
match &field_name.to_string()[..] {
|
||||
"owners" => {
|
||||
if request.owners.is_none() {
|
||||
request.owners = Some(Default::default());
|
||||
request.owners = Some(Default::default());
|
||||
}
|
||||
request.owners.as_mut().unwrap().push(value.unwrap_or("").to_string());
|
||||
request.owners.as_mut().unwrap().push(value.unwrap_or("").to_string());
|
||||
},
|
||||
"id" => {
|
||||
request.id = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
"site.identifier" => {
|
||||
request_site_init(&mut request);
|
||||
request.site.as_mut().unwrap().identifier = value.unwrap_or("").to_string();
|
||||
request.site.as_mut().unwrap().identifier = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
"site.type" => {
|
||||
request_site_init(&mut request);
|
||||
request.site.as_mut().unwrap().type_ = value.unwrap_or("").to_string();
|
||||
request.site.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
_ => {
|
||||
err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string())));
|
||||
@@ -289,8 +295,7 @@ impl Engine {
|
||||
} {
|
||||
Err(api_err) => Some(api_err),
|
||||
Ok((mut response, output_schema)) => {
|
||||
println!("DEBUG: REMOVE ME {:?}", response);
|
||||
serde::json::to_writer(&mut ostream, &output_schema).unwrap();
|
||||
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -301,7 +306,7 @@ impl Engine {
|
||||
-> Option<api::Error> {
|
||||
let mut call = self.hub.web_resource().list();
|
||||
for parg in self.opt.arg_v.iter() {
|
||||
let (key, value) = parse_kv_arg(&*parg, err);
|
||||
let (key, value) = parse_kv_arg(&*parg, err, false);
|
||||
match key {
|
||||
"alt"
|
||||
|"fields"
|
||||
@@ -333,8 +338,7 @@ impl Engine {
|
||||
} {
|
||||
Err(api_err) => Some(api_err),
|
||||
Ok((mut response, output_schema)) => {
|
||||
println!("DEBUG: REMOVE ME {:?}", response);
|
||||
serde::json::to_writer(&mut ostream, &output_schema).unwrap();
|
||||
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -343,10 +347,10 @@ impl Engine {
|
||||
|
||||
fn _web_resource_patch(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Option<api::Error> {
|
||||
let mut request: api::SiteVerificationWebResourceResource = Default::default();
|
||||
let mut request = api::SiteVerificationWebResourceResource::default();
|
||||
let mut call = self.hub.web_resource().patch(&request, &self.opt.arg_id);
|
||||
for parg in self.opt.arg_v.iter() {
|
||||
let (key, value) = parse_kv_arg(&*parg, err);
|
||||
let (key, value) = parse_kv_arg(&*parg, err, false);
|
||||
match key {
|
||||
"alt"
|
||||
|"fields"
|
||||
@@ -366,9 +370,10 @@ impl Engine {
|
||||
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
||||
}
|
||||
}
|
||||
let mut field_name: FieldCursor = Default::default();
|
||||
|
||||
let mut field_name = FieldCursor::default();
|
||||
for kvarg in self.opt.arg_kv.iter() {
|
||||
let (key, value) = parse_kv_arg(&*kvarg, err);
|
||||
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
||||
if let Err(field_err) = field_name.set(&*key) {
|
||||
err.issues.push(field_err);
|
||||
}
|
||||
@@ -381,20 +386,20 @@ impl Engine {
|
||||
match &field_name.to_string()[..] {
|
||||
"owners" => {
|
||||
if request.owners.is_none() {
|
||||
request.owners = Some(Default::default());
|
||||
request.owners = Some(Default::default());
|
||||
}
|
||||
request.owners.as_mut().unwrap().push(value.unwrap_or("").to_string());
|
||||
request.owners.as_mut().unwrap().push(value.unwrap_or("").to_string());
|
||||
},
|
||||
"id" => {
|
||||
request.id = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
"site.identifier" => {
|
||||
request_site_init(&mut request);
|
||||
request.site.as_mut().unwrap().identifier = value.unwrap_or("").to_string();
|
||||
request.site.as_mut().unwrap().identifier = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
"site.type" => {
|
||||
request_site_init(&mut request);
|
||||
request.site.as_mut().unwrap().type_ = value.unwrap_or("").to_string();
|
||||
request.site.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
_ => {
|
||||
err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string())));
|
||||
@@ -413,8 +418,7 @@ impl Engine {
|
||||
} {
|
||||
Err(api_err) => Some(api_err),
|
||||
Ok((mut response, output_schema)) => {
|
||||
println!("DEBUG: REMOVE ME {:?}", response);
|
||||
serde::json::to_writer(&mut ostream, &output_schema).unwrap();
|
||||
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -423,10 +427,10 @@ impl Engine {
|
||||
|
||||
fn _web_resource_update(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Option<api::Error> {
|
||||
let mut request: api::SiteVerificationWebResourceResource = Default::default();
|
||||
let mut request = api::SiteVerificationWebResourceResource::default();
|
||||
let mut call = self.hub.web_resource().update(&request, &self.opt.arg_id);
|
||||
for parg in self.opt.arg_v.iter() {
|
||||
let (key, value) = parse_kv_arg(&*parg, err);
|
||||
let (key, value) = parse_kv_arg(&*parg, err, false);
|
||||
match key {
|
||||
"alt"
|
||||
|"fields"
|
||||
@@ -446,9 +450,10 @@ impl Engine {
|
||||
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
||||
}
|
||||
}
|
||||
let mut field_name: FieldCursor = Default::default();
|
||||
|
||||
let mut field_name = FieldCursor::default();
|
||||
for kvarg in self.opt.arg_kv.iter() {
|
||||
let (key, value) = parse_kv_arg(&*kvarg, err);
|
||||
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
||||
if let Err(field_err) = field_name.set(&*key) {
|
||||
err.issues.push(field_err);
|
||||
}
|
||||
@@ -461,20 +466,20 @@ impl Engine {
|
||||
match &field_name.to_string()[..] {
|
||||
"owners" => {
|
||||
if request.owners.is_none() {
|
||||
request.owners = Some(Default::default());
|
||||
request.owners = Some(Default::default());
|
||||
}
|
||||
request.owners.as_mut().unwrap().push(value.unwrap_or("").to_string());
|
||||
request.owners.as_mut().unwrap().push(value.unwrap_or("").to_string());
|
||||
},
|
||||
"id" => {
|
||||
request.id = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
"site.identifier" => {
|
||||
request_site_init(&mut request);
|
||||
request.site.as_mut().unwrap().identifier = value.unwrap_or("").to_string();
|
||||
request.site.as_mut().unwrap().identifier = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
"site.type" => {
|
||||
request_site_init(&mut request);
|
||||
request.site.as_mut().unwrap().type_ = value.unwrap_or("").to_string();
|
||||
request.site.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
_ => {
|
||||
err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string())));
|
||||
@@ -493,8 +498,7 @@ impl Engine {
|
||||
} {
|
||||
Err(api_err) => Some(api_err),
|
||||
Ok((mut response, output_schema)) => {
|
||||
println!("DEBUG: REMOVE ME {:?}", response);
|
||||
serde::json::to_writer(&mut ostream, &output_schema).unwrap();
|
||||
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -544,21 +548,37 @@ impl Engine {
|
||||
Ok(p) => p,
|
||||
};
|
||||
|
||||
match cmn::application_secret_from_directory(&config_dir, "siteverification1-secret.json") {
|
||||
match cmn::application_secret_from_directory(&config_dir, "siteverification1-secret.json",
|
||||
"{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") {
|
||||
Ok(secret) => (config_dir, secret),
|
||||
Err(e) => return Err(InvalidOptionsError::single(e, 4))
|
||||
}
|
||||
};
|
||||
|
||||
let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||||
hyper::Client::new(),
|
||||
JsonTokenStorage {
|
||||
program_name: "siteverification1",
|
||||
db_dir: config_dir.clone(),
|
||||
}, None);
|
||||
let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate,
|
||||
if opt.flag_debug_auth {
|
||||
hyper::Client::with_connector(mock::TeeConnector {
|
||||
connector: hyper::net::HttpConnector(None)
|
||||
})
|
||||
} else {
|
||||
hyper::Client::new()
|
||||
},
|
||||
JsonTokenStorage {
|
||||
program_name: "siteverification1",
|
||||
db_dir: config_dir.clone(),
|
||||
}, None);
|
||||
|
||||
let client =
|
||||
if opt.flag_debug {
|
||||
hyper::Client::with_connector(mock::TeeConnector {
|
||||
connector: hyper::net::HttpConnector(None)
|
||||
})
|
||||
} else {
|
||||
hyper::Client::new()
|
||||
};
|
||||
let engine = Engine {
|
||||
opt: opt,
|
||||
hub: api::SiteVerification::new(hyper::Client::new(), auth),
|
||||
hub: api::SiteVerification::new(client, auth),
|
||||
};
|
||||
|
||||
match engine._doit(true) {
|
||||
@@ -578,12 +598,13 @@ fn main() {
|
||||
let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit());
|
||||
match Engine::new(opts) {
|
||||
Err(err) => {
|
||||
write!(io::stderr(), "{}", err).ok();
|
||||
writeln!(io::stderr(), "{}", err).ok();
|
||||
env::set_exit_status(err.exit_code);
|
||||
},
|
||||
Ok(engine) => {
|
||||
if let Some(err) = engine.doit() {
|
||||
write!(io::stderr(), "{}", err).ok();
|
||||
writeln!(io::stderr(), "{:?}", err).ok();
|
||||
writeln!(io::stderr(), "{}", err).ok();
|
||||
env::set_exit_status(1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user