From a8d333f91681010f9c5a52c50339d9d36ea49dc3 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 29 Sep 2015 11:35:13 +0200 Subject: [PATCH] chore(codegen): code compiles with rust 1.3/serde 0.6 --- gen/adexchangebuyer1d3-cli/Cargo.toml | 4 +- gen/adexchangebuyer1d3-cli/src/cmn.rs | 75 ++++++++++--------- gen/adexchangebuyer1d3/Cargo.toml | 4 +- gen/adexchangeseller2-cli/Cargo.toml | 4 +- gen/adexchangeseller2-cli/src/cmn.rs | 75 ++++++++++--------- gen/adexchangeseller2/Cargo.toml | 4 +- gen/admin1_directory-cli/Cargo.toml | 4 +- gen/admin1_directory-cli/src/cmn.rs | 75 ++++++++++--------- gen/admin1_directory/Cargo.toml | 4 +- gen/admin1_reports-cli/Cargo.toml | 4 +- gen/admin1_reports-cli/src/cmn.rs | 75 ++++++++++--------- gen/admin1_reports/Cargo.toml | 4 +- gen/admin2_email_migration-cli/Cargo.toml | 4 +- gen/admin2_email_migration-cli/src/cmn.rs | 75 ++++++++++--------- gen/admin2_email_migration/Cargo.toml | 4 +- gen/adsense1d4-cli/Cargo.toml | 4 +- gen/adsense1d4-cli/src/cmn.rs | 75 ++++++++++--------- gen/adsense1d4/Cargo.toml | 4 +- gen/adsensehost4d1-cli/Cargo.toml | 4 +- gen/adsensehost4d1-cli/src/cmn.rs | 75 ++++++++++--------- gen/adsensehost4d1/Cargo.toml | 4 +- gen/analytics3-cli/Cargo.toml | 4 +- gen/analytics3-cli/src/cmn.rs | 75 ++++++++++--------- gen/analytics3/Cargo.toml | 4 +- gen/androidenterprise1-cli/Cargo.toml | 4 +- gen/androidenterprise1-cli/src/cmn.rs | 75 ++++++++++--------- gen/androidenterprise1/Cargo.toml | 4 +- gen/androidpublisher2-cli/Cargo.toml | 4 +- gen/androidpublisher2-cli/src/cmn.rs | 75 ++++++++++--------- gen/androidpublisher2/Cargo.toml | 4 +- gen/appsactivity1-cli/Cargo.toml | 4 +- gen/appsactivity1-cli/src/cmn.rs | 75 ++++++++++--------- gen/appsactivity1/Cargo.toml | 4 +- gen/appstate1-cli/Cargo.toml | 4 +- gen/appstate1-cli/src/cmn.rs | 75 ++++++++++--------- gen/appstate1/Cargo.toml | 4 +- gen/audit1-cli/Cargo.toml | 4 +- gen/audit1-cli/src/cmn.rs | 75 ++++++++++--------- gen/audit1/Cargo.toml | 4 +- gen/autoscaler1_beta2-cli/Cargo.toml | 4 +- gen/autoscaler1_beta2-cli/src/cmn.rs | 75 ++++++++++--------- gen/autoscaler1_beta2/Cargo.toml | 4 +- gen/bigquery2-cli/Cargo.toml | 4 +- gen/bigquery2-cli/src/cmn.rs | 75 ++++++++++--------- gen/bigquery2/Cargo.toml | 4 +- gen/blogger3-cli/Cargo.toml | 4 +- gen/blogger3-cli/src/cmn.rs | 75 ++++++++++--------- gen/blogger3/Cargo.toml | 4 +- gen/books1-cli/Cargo.toml | 4 +- gen/books1-cli/src/cmn.rs | 75 ++++++++++--------- gen/books1/Cargo.toml | 4 +- gen/calendar3-cli/Cargo.toml | 4 +- gen/calendar3-cli/src/cmn.rs | 75 ++++++++++--------- gen/calendar3/Cargo.toml | 4 +- gen/civicinfo2-cli/Cargo.toml | 4 +- gen/civicinfo2-cli/src/cmn.rs | 75 ++++++++++--------- gen/civicinfo2/Cargo.toml | 4 +- gen/cloudlatencytest2-cli/Cargo.toml | 4 +- gen/cloudlatencytest2-cli/src/cmn.rs | 75 ++++++++++--------- gen/cloudlatencytest2/Cargo.toml | 4 +- gen/cloudmonitoring2_beta2-cli/Cargo.toml | 4 +- gen/cloudmonitoring2_beta2-cli/src/cmn.rs | 75 ++++++++++--------- gen/cloudmonitoring2_beta2/Cargo.toml | 4 +- .../Cargo.toml | 4 +- .../src/cmn.rs | 75 ++++++++++--------- gen/cloudresourcemanager1_beta1/Cargo.toml | 4 +- gen/compute1-cli/Cargo.toml | 4 +- gen/compute1-cli/src/cmn.rs | 75 ++++++++++--------- gen/compute1/Cargo.toml | 4 +- gen/container1_beta1-cli/Cargo.toml | 4 +- gen/container1_beta1-cli/src/cmn.rs | 75 ++++++++++--------- gen/container1_beta1/Cargo.toml | 4 +- gen/content2-cli/Cargo.toml | 4 +- gen/content2-cli/src/cmn.rs | 75 ++++++++++--------- gen/content2/Cargo.toml | 4 +- gen/coordinate1-cli/Cargo.toml | 4 +- gen/coordinate1-cli/src/cmn.rs | 75 ++++++++++--------- gen/coordinate1/Cargo.toml | 4 +- gen/customsearch1-cli/Cargo.toml | 4 +- gen/customsearch1-cli/src/cmn.rs | 75 ++++++++++--------- gen/customsearch1/Cargo.toml | 4 +- gen/datastore1_beta2-cli/Cargo.toml | 4 +- gen/datastore1_beta2-cli/src/cmn.rs | 75 ++++++++++--------- gen/datastore1_beta2/Cargo.toml | 4 +- gen/deploymentmanager2_beta2-cli/Cargo.toml | 4 +- gen/deploymentmanager2_beta2-cli/src/cmn.rs | 75 ++++++++++--------- gen/deploymentmanager2_beta2/Cargo.toml | 4 +- gen/dfareporting2d1-cli/Cargo.toml | 4 +- gen/dfareporting2d1-cli/src/cmn.rs | 75 ++++++++++--------- gen/dfareporting2d1/Cargo.toml | 4 +- gen/discovery1-cli/Cargo.toml | 4 +- gen/discovery1-cli/src/cmn.rs | 75 ++++++++++--------- gen/discovery1/Cargo.toml | 4 +- gen/dns1-cli/Cargo.toml | 4 +- gen/dns1-cli/src/cmn.rs | 75 ++++++++++--------- gen/dns1/Cargo.toml | 4 +- gen/doubleclickbidmanager1-cli/Cargo.toml | 4 +- gen/doubleclickbidmanager1-cli/src/cmn.rs | 75 ++++++++++--------- gen/doubleclickbidmanager1/Cargo.toml | 4 +- gen/doubleclicksearch2-cli/Cargo.toml | 4 +- gen/doubleclicksearch2-cli/src/cmn.rs | 75 ++++++++++--------- gen/doubleclicksearch2/Cargo.toml | 4 +- gen/drive2-cli/Cargo.toml | 4 +- gen/drive2-cli/src/cmn.rs | 75 ++++++++++--------- gen/drive2/Cargo.toml | 4 +- gen/fitness1-cli/Cargo.toml | 4 +- gen/fitness1-cli/src/cmn.rs | 75 ++++++++++--------- gen/fitness1/Cargo.toml | 4 +- gen/freebase1-cli/Cargo.toml | 4 +- gen/freebase1-cli/src/cmn.rs | 75 ++++++++++--------- gen/freebase1/Cargo.toml | 4 +- gen/freebase1_sandbox-cli/Cargo.toml | 4 +- gen/freebase1_sandbox-cli/src/cmn.rs | 75 ++++++++++--------- gen/freebase1_sandbox/Cargo.toml | 4 +- gen/fusiontables2-cli/Cargo.toml | 4 +- gen/fusiontables2-cli/src/cmn.rs | 75 ++++++++++--------- gen/fusiontables2/Cargo.toml | 4 +- gen/games1-cli/Cargo.toml | 4 +- gen/games1-cli/src/cmn.rs | 75 ++++++++++--------- gen/games1/Cargo.toml | 4 +- .../Cargo.toml | 4 +- .../src/cmn.rs | 75 ++++++++++--------- .../Cargo.toml | 4 +- .../Cargo.toml | 4 +- .../src/cmn.rs | 75 ++++++++++--------- gen/gamesmanagement1_management/Cargo.toml | 4 +- gen/gan1_beta1-cli/Cargo.toml | 4 +- gen/gan1_beta1-cli/src/cmn.rs | 75 ++++++++++--------- gen/gan1_beta1/Cargo.toml | 4 +- gen/genomics1-cli/Cargo.toml | 4 +- gen/genomics1-cli/src/cmn.rs | 75 ++++++++++--------- gen/genomics1/Cargo.toml | 4 +- gen/gmail1-cli/Cargo.toml | 4 +- gen/gmail1-cli/src/cmn.rs | 75 ++++++++++--------- gen/gmail1/Cargo.toml | 4 +- gen/groupsmigration1-cli/Cargo.toml | 4 +- gen/groupsmigration1-cli/src/cmn.rs | 75 ++++++++++--------- gen/groupsmigration1/Cargo.toml | 4 +- gen/groupssettings1-cli/Cargo.toml | 4 +- gen/groupssettings1-cli/src/cmn.rs | 75 ++++++++++--------- gen/groupssettings1/Cargo.toml | 4 +- gen/identitytoolkit3-cli/Cargo.toml | 4 +- gen/identitytoolkit3-cli/src/cmn.rs | 75 ++++++++++--------- gen/identitytoolkit3/Cargo.toml | 4 +- gen/licensing1-cli/Cargo.toml | 4 +- gen/licensing1-cli/src/cmn.rs | 75 ++++++++++--------- gen/licensing1/Cargo.toml | 4 +- gen/logging1_beta3-cli/Cargo.toml | 4 +- gen/logging1_beta3-cli/src/cmn.rs | 75 ++++++++++--------- gen/logging1_beta3/Cargo.toml | 4 +- gen/manager1_beta2-cli/Cargo.toml | 4 +- gen/manager1_beta2-cli/src/cmn.rs | 75 ++++++++++--------- gen/manager1_beta2/Cargo.toml | 4 +- gen/mapsengine1-cli/Cargo.toml | 4 +- gen/mapsengine1-cli/src/cmn.rs | 75 ++++++++++--------- gen/mapsengine1/Cargo.toml | 4 +- gen/mirror1-cli/Cargo.toml | 4 +- gen/mirror1-cli/src/cmn.rs | 75 ++++++++++--------- gen/mirror1/Cargo.toml | 4 +- gen/oauth2_v2-cli/Cargo.toml | 4 +- gen/oauth2_v2-cli/src/cmn.rs | 75 ++++++++++--------- gen/oauth2_v2/Cargo.toml | 4 +- gen/pagespeedonline2-cli/Cargo.toml | 4 +- gen/pagespeedonline2-cli/src/cmn.rs | 75 ++++++++++--------- gen/pagespeedonline2/Cargo.toml | 4 +- gen/plus1-cli/Cargo.toml | 4 +- gen/plus1-cli/src/cmn.rs | 75 ++++++++++--------- gen/plus1/Cargo.toml | 4 +- gen/plusdomains1-cli/Cargo.toml | 4 +- gen/plusdomains1-cli/src/cmn.rs | 75 ++++++++++--------- gen/plusdomains1/Cargo.toml | 4 +- gen/prediction1d6-cli/Cargo.toml | 4 +- gen/prediction1d6-cli/src/cmn.rs | 75 ++++++++++--------- gen/prediction1d6/Cargo.toml | 4 +- gen/pubsub1_beta2-cli/Cargo.toml | 4 +- gen/pubsub1_beta2-cli/src/cmn.rs | 75 ++++++++++--------- gen/pubsub1_beta2/Cargo.toml | 4 +- gen/qpxexpress1-cli/Cargo.toml | 4 +- gen/qpxexpress1-cli/src/cmn.rs | 75 ++++++++++--------- gen/qpxexpress1/Cargo.toml | 4 +- gen/replicapool1_beta2-cli/Cargo.toml | 4 +- gen/replicapool1_beta2-cli/src/cmn.rs | 75 ++++++++++--------- gen/replicapool1_beta2/Cargo.toml | 4 +- gen/replicapoolupdater1_beta1-cli/Cargo.toml | 4 +- gen/replicapoolupdater1_beta1-cli/src/cmn.rs | 75 ++++++++++--------- gen/replicapoolupdater1_beta1/Cargo.toml | 4 +- gen/reseller1_sandbox-cli/Cargo.toml | 4 +- gen/reseller1_sandbox-cli/src/cmn.rs | 75 ++++++++++--------- gen/reseller1_sandbox/Cargo.toml | 4 +- gen/resourceviews1_beta2-cli/Cargo.toml | 4 +- gen/resourceviews1_beta2-cli/src/cmn.rs | 75 ++++++++++--------- gen/resourceviews1_beta2/Cargo.toml | 4 +- gen/siteverification1-cli/Cargo.toml | 4 +- gen/siteverification1-cli/src/cmn.rs | 75 ++++++++++--------- gen/siteverification1/Cargo.toml | 4 +- gen/spectrum1_explorer-cli/Cargo.toml | 4 +- gen/spectrum1_explorer-cli/src/cmn.rs | 75 ++++++++++--------- gen/spectrum1_explorer/Cargo.toml | 4 +- gen/sqladmin1_beta4-cli/Cargo.toml | 4 +- gen/sqladmin1_beta4-cli/src/cmn.rs | 75 ++++++++++--------- gen/sqladmin1_beta4/Cargo.toml | 4 +- gen/storage1-cli/Cargo.toml | 4 +- gen/storage1-cli/src/cmn.rs | 75 ++++++++++--------- gen/storage1/Cargo.toml | 4 +- gen/tagmanager1-cli/Cargo.toml | 4 +- gen/tagmanager1-cli/src/cmn.rs | 75 ++++++++++--------- gen/tagmanager1/Cargo.toml | 4 +- gen/taskqueue1_beta2-cli/Cargo.toml | 4 +- gen/taskqueue1_beta2-cli/src/cmn.rs | 75 ++++++++++--------- gen/taskqueue1_beta2/Cargo.toml | 4 +- gen/tasks1-cli/Cargo.toml | 4 +- gen/tasks1-cli/src/cmn.rs | 75 ++++++++++--------- gen/tasks1/Cargo.toml | 4 +- gen/translate2-cli/Cargo.toml | 4 +- gen/translate2-cli/src/cmn.rs | 75 ++++++++++--------- gen/translate2/Cargo.toml | 4 +- gen/urlshortener1-cli/Cargo.toml | 4 +- gen/urlshortener1-cli/src/cmn.rs | 75 ++++++++++--------- gen/urlshortener1/Cargo.toml | 4 +- gen/webfonts1-cli/Cargo.toml | 4 +- gen/webfonts1-cli/src/cmn.rs | 75 ++++++++++--------- gen/webfonts1/Cargo.toml | 4 +- gen/webmasters3-cli/Cargo.toml | 4 +- gen/webmasters3-cli/src/cmn.rs | 75 ++++++++++--------- gen/webmasters3/Cargo.toml | 4 +- gen/youtube3-cli/Cargo.toml | 4 +- gen/youtube3-cli/src/cmn.rs | 75 ++++++++++--------- gen/youtube3/cargo.toml | 4 +- gen/youtubeanalytics1-cli/Cargo.toml | 4 +- gen/youtubeanalytics1-cli/src/cmn.rs | 75 ++++++++++--------- gen/youtubeanalytics1/Cargo.toml | 4 +- 231 files changed, 3311 insertions(+), 3080 deletions(-) diff --git a/gen/adexchangebuyer1d3-cli/Cargo.toml b/gen/adexchangebuyer1d3-cli/Cargo.toml index 65ab7446c1..f803de55b9 100644 --- a/gen/adexchangebuyer1d3-cli/Cargo.toml +++ b/gen/adexchangebuyer1d3-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "adexchangebuyer1d3" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/adexchangebuyer1d3-cli/src/cmn.rs b/gen/adexchangebuyer1d3-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/adexchangebuyer1d3-cli/src/cmn.rs +++ b/gen/adexchangebuyer1d3-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/adexchangebuyer1d3/Cargo.toml b/gen/adexchangebuyer1d3/Cargo.toml index ec4a2eef43..aaa92d10f2 100644 --- a/gen/adexchangebuyer1d3/Cargo.toml +++ b/gen/adexchangebuyer1d3/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/adexchangeseller2-cli/Cargo.toml b/gen/adexchangeseller2-cli/Cargo.toml index 44bdb4d379..5451ba3dc5 100644 --- a/gen/adexchangeseller2-cli/Cargo.toml +++ b/gen/adexchangeseller2-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "adexchangeseller2" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/adexchangeseller2-cli/src/cmn.rs b/gen/adexchangeseller2-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/adexchangeseller2-cli/src/cmn.rs +++ b/gen/adexchangeseller2-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/adexchangeseller2/Cargo.toml b/gen/adexchangeseller2/Cargo.toml index a402a66bc9..a9e17244d9 100644 --- a/gen/adexchangeseller2/Cargo.toml +++ b/gen/adexchangeseller2/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/admin1_directory-cli/Cargo.toml b/gen/admin1_directory-cli/Cargo.toml index f41dd1096a..05f3cf020d 100644 --- a/gen/admin1_directory-cli/Cargo.toml +++ b/gen/admin1_directory-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "admin1-directory" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/admin1_directory-cli/src/cmn.rs b/gen/admin1_directory-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/admin1_directory-cli/src/cmn.rs +++ b/gen/admin1_directory-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/admin1_directory/Cargo.toml b/gen/admin1_directory/Cargo.toml index 432c624280..ec63d1519d 100644 --- a/gen/admin1_directory/Cargo.toml +++ b/gen/admin1_directory/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/admin1_reports-cli/Cargo.toml b/gen/admin1_reports-cli/Cargo.toml index 1ee58d1646..baa5a2d4f0 100644 --- a/gen/admin1_reports-cli/Cargo.toml +++ b/gen/admin1_reports-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "admin1-reports" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/admin1_reports-cli/src/cmn.rs b/gen/admin1_reports-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/admin1_reports-cli/src/cmn.rs +++ b/gen/admin1_reports-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/admin1_reports/Cargo.toml b/gen/admin1_reports/Cargo.toml index 31e9636cb2..5494a27fcd 100644 --- a/gen/admin1_reports/Cargo.toml +++ b/gen/admin1_reports/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/admin2_email_migration-cli/Cargo.toml b/gen/admin2_email_migration-cli/Cargo.toml index 8963d5a24f..312fc73852 100644 --- a/gen/admin2_email_migration-cli/Cargo.toml +++ b/gen/admin2_email_migration-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "admin2-email-migration" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/admin2_email_migration-cli/src/cmn.rs b/gen/admin2_email_migration-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/admin2_email_migration-cli/src/cmn.rs +++ b/gen/admin2_email_migration-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/admin2_email_migration/Cargo.toml b/gen/admin2_email_migration/Cargo.toml index 6a728c0f57..70b443da33 100644 --- a/gen/admin2_email_migration/Cargo.toml +++ b/gen/admin2_email_migration/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/adsense1d4-cli/Cargo.toml b/gen/adsense1d4-cli/Cargo.toml index 9b75bfed94..5093cfcdbb 100644 --- a/gen/adsense1d4-cli/Cargo.toml +++ b/gen/adsense1d4-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "adsense1d4" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/adsense1d4-cli/src/cmn.rs b/gen/adsense1d4-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/adsense1d4-cli/src/cmn.rs +++ b/gen/adsense1d4-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/adsense1d4/Cargo.toml b/gen/adsense1d4/Cargo.toml index 3d532780a2..cf142bc6c5 100644 --- a/gen/adsense1d4/Cargo.toml +++ b/gen/adsense1d4/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/adsensehost4d1-cli/Cargo.toml b/gen/adsensehost4d1-cli/Cargo.toml index 5e999b2afc..8895af05e0 100644 --- a/gen/adsensehost4d1-cli/Cargo.toml +++ b/gen/adsensehost4d1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "adsensehost4d1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/adsensehost4d1-cli/src/cmn.rs b/gen/adsensehost4d1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/adsensehost4d1-cli/src/cmn.rs +++ b/gen/adsensehost4d1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/adsensehost4d1/Cargo.toml b/gen/adsensehost4d1/Cargo.toml index 2e5b070884..22db79393f 100644 --- a/gen/adsensehost4d1/Cargo.toml +++ b/gen/adsensehost4d1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/analytics3-cli/Cargo.toml b/gen/analytics3-cli/Cargo.toml index 134f8714be..7a9d7185e7 100644 --- a/gen/analytics3-cli/Cargo.toml +++ b/gen/analytics3-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "analytics3" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/analytics3-cli/src/cmn.rs b/gen/analytics3-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/analytics3-cli/src/cmn.rs +++ b/gen/analytics3-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/analytics3/Cargo.toml b/gen/analytics3/Cargo.toml index 7f9a6ce5f8..0c75a1658f 100644 --- a/gen/analytics3/Cargo.toml +++ b/gen/analytics3/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/androidenterprise1-cli/Cargo.toml b/gen/androidenterprise1-cli/Cargo.toml index 92830f134e..951685c14b 100644 --- a/gen/androidenterprise1-cli/Cargo.toml +++ b/gen/androidenterprise1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "androidenterprise1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/androidenterprise1-cli/src/cmn.rs b/gen/androidenterprise1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/androidenterprise1-cli/src/cmn.rs +++ b/gen/androidenterprise1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/androidenterprise1/Cargo.toml b/gen/androidenterprise1/Cargo.toml index 3af1971366..f427206c56 100644 --- a/gen/androidenterprise1/Cargo.toml +++ b/gen/androidenterprise1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/androidpublisher2-cli/Cargo.toml b/gen/androidpublisher2-cli/Cargo.toml index f99acf6f2a..0195d5400b 100644 --- a/gen/androidpublisher2-cli/Cargo.toml +++ b/gen/androidpublisher2-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "androidpublisher2" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/androidpublisher2-cli/src/cmn.rs b/gen/androidpublisher2-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/androidpublisher2-cli/src/cmn.rs +++ b/gen/androidpublisher2-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/androidpublisher2/Cargo.toml b/gen/androidpublisher2/Cargo.toml index 75eab6e4b2..55c1d0c93d 100644 --- a/gen/androidpublisher2/Cargo.toml +++ b/gen/androidpublisher2/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/appsactivity1-cli/Cargo.toml b/gen/appsactivity1-cli/Cargo.toml index 2357d0f9b4..4f209d8c7c 100644 --- a/gen/appsactivity1-cli/Cargo.toml +++ b/gen/appsactivity1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "appsactivity1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/appsactivity1-cli/src/cmn.rs b/gen/appsactivity1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/appsactivity1-cli/src/cmn.rs +++ b/gen/appsactivity1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/appsactivity1/Cargo.toml b/gen/appsactivity1/Cargo.toml index d4456a6373..6e32570fb6 100644 --- a/gen/appsactivity1/Cargo.toml +++ b/gen/appsactivity1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/appstate1-cli/Cargo.toml b/gen/appstate1-cli/Cargo.toml index 37f6cb21a7..e8170d65b4 100644 --- a/gen/appstate1-cli/Cargo.toml +++ b/gen/appstate1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "appstate1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/appstate1-cli/src/cmn.rs b/gen/appstate1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/appstate1-cli/src/cmn.rs +++ b/gen/appstate1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/appstate1/Cargo.toml b/gen/appstate1/Cargo.toml index 7ad16e467d..0f0d40c131 100644 --- a/gen/appstate1/Cargo.toml +++ b/gen/appstate1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/audit1-cli/Cargo.toml b/gen/audit1-cli/Cargo.toml index 0928d5c26e..77012819c7 100644 --- a/gen/audit1-cli/Cargo.toml +++ b/gen/audit1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "audit1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/audit1-cli/src/cmn.rs b/gen/audit1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/audit1-cli/src/cmn.rs +++ b/gen/audit1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/audit1/Cargo.toml b/gen/audit1/Cargo.toml index efe646a1a0..befb15c061 100644 --- a/gen/audit1/Cargo.toml +++ b/gen/audit1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/autoscaler1_beta2-cli/Cargo.toml b/gen/autoscaler1_beta2-cli/Cargo.toml index 699198f774..d6f48a61cc 100644 --- a/gen/autoscaler1_beta2-cli/Cargo.toml +++ b/gen/autoscaler1_beta2-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "autoscaler1-beta2" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/autoscaler1_beta2-cli/src/cmn.rs b/gen/autoscaler1_beta2-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/autoscaler1_beta2-cli/src/cmn.rs +++ b/gen/autoscaler1_beta2-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/autoscaler1_beta2/Cargo.toml b/gen/autoscaler1_beta2/Cargo.toml index a3d1132a11..e65bf745a7 100644 --- a/gen/autoscaler1_beta2/Cargo.toml +++ b/gen/autoscaler1_beta2/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/bigquery2-cli/Cargo.toml b/gen/bigquery2-cli/Cargo.toml index 53e96db961..05adacc9c1 100644 --- a/gen/bigquery2-cli/Cargo.toml +++ b/gen/bigquery2-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "bigquery2" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/bigquery2-cli/src/cmn.rs b/gen/bigquery2-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/bigquery2-cli/src/cmn.rs +++ b/gen/bigquery2-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/bigquery2/Cargo.toml b/gen/bigquery2/Cargo.toml index cc4dd0f5a5..95287e424d 100644 --- a/gen/bigquery2/Cargo.toml +++ b/gen/bigquery2/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/blogger3-cli/Cargo.toml b/gen/blogger3-cli/Cargo.toml index b76eaa3107..eb4a16c28a 100644 --- a/gen/blogger3-cli/Cargo.toml +++ b/gen/blogger3-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "blogger3" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/blogger3-cli/src/cmn.rs b/gen/blogger3-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/blogger3-cli/src/cmn.rs +++ b/gen/blogger3-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/blogger3/Cargo.toml b/gen/blogger3/Cargo.toml index 0c426e7da6..2d4c8d3f9a 100644 --- a/gen/blogger3/Cargo.toml +++ b/gen/blogger3/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/books1-cli/Cargo.toml b/gen/books1-cli/Cargo.toml index dd7c0c9f94..28eb93853c 100644 --- a/gen/books1-cli/Cargo.toml +++ b/gen/books1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "books1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/books1-cli/src/cmn.rs b/gen/books1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/books1-cli/src/cmn.rs +++ b/gen/books1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/books1/Cargo.toml b/gen/books1/Cargo.toml index b132a484fa..c597d65913 100644 --- a/gen/books1/Cargo.toml +++ b/gen/books1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/calendar3-cli/Cargo.toml b/gen/calendar3-cli/Cargo.toml index 5958761203..fd474bfd10 100644 --- a/gen/calendar3-cli/Cargo.toml +++ b/gen/calendar3-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "calendar3" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/calendar3-cli/src/cmn.rs b/gen/calendar3-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/calendar3-cli/src/cmn.rs +++ b/gen/calendar3-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/calendar3/Cargo.toml b/gen/calendar3/Cargo.toml index 5128b249c2..2aadb9b0ac 100644 --- a/gen/calendar3/Cargo.toml +++ b/gen/calendar3/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/civicinfo2-cli/Cargo.toml b/gen/civicinfo2-cli/Cargo.toml index e2eeb3c6a9..c54a33fe6c 100644 --- a/gen/civicinfo2-cli/Cargo.toml +++ b/gen/civicinfo2-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "civicinfo2" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/civicinfo2-cli/src/cmn.rs b/gen/civicinfo2-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/civicinfo2-cli/src/cmn.rs +++ b/gen/civicinfo2-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/civicinfo2/Cargo.toml b/gen/civicinfo2/Cargo.toml index 7a092f9820..5be4f02584 100644 --- a/gen/civicinfo2/Cargo.toml +++ b/gen/civicinfo2/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/cloudlatencytest2-cli/Cargo.toml b/gen/cloudlatencytest2-cli/Cargo.toml index 72a99d582d..43b4a69c1b 100644 --- a/gen/cloudlatencytest2-cli/Cargo.toml +++ b/gen/cloudlatencytest2-cli/Cargo.toml @@ -18,8 +18,8 @@ name = "cloudlatencytest2" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/cloudlatencytest2-cli/src/cmn.rs b/gen/cloudlatencytest2-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/cloudlatencytest2-cli/src/cmn.rs +++ b/gen/cloudlatencytest2-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/cloudlatencytest2/Cargo.toml b/gen/cloudlatencytest2/Cargo.toml index ee330781dd..727fb39498 100644 --- a/gen/cloudlatencytest2/Cargo.toml +++ b/gen/cloudlatencytest2/Cargo.toml @@ -17,8 +17,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/cloudmonitoring2_beta2-cli/Cargo.toml b/gen/cloudmonitoring2_beta2-cli/Cargo.toml index 42c579fe9a..13d26e3a87 100644 --- a/gen/cloudmonitoring2_beta2-cli/Cargo.toml +++ b/gen/cloudmonitoring2_beta2-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "cloudmonitoring2-beta2" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/cloudmonitoring2_beta2-cli/src/cmn.rs b/gen/cloudmonitoring2_beta2-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/cloudmonitoring2_beta2-cli/src/cmn.rs +++ b/gen/cloudmonitoring2_beta2-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/cloudmonitoring2_beta2/Cargo.toml b/gen/cloudmonitoring2_beta2/Cargo.toml index 39e9ecd952..f850f25c4c 100644 --- a/gen/cloudmonitoring2_beta2/Cargo.toml +++ b/gen/cloudmonitoring2_beta2/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/cloudresourcemanager1_beta1-cli/Cargo.toml b/gen/cloudresourcemanager1_beta1-cli/Cargo.toml index e090601c17..d92f6d2c19 100644 --- a/gen/cloudresourcemanager1_beta1-cli/Cargo.toml +++ b/gen/cloudresourcemanager1_beta1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "cloudresourcemanager1-beta1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/cloudresourcemanager1_beta1-cli/src/cmn.rs b/gen/cloudresourcemanager1_beta1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/cloudresourcemanager1_beta1-cli/src/cmn.rs +++ b/gen/cloudresourcemanager1_beta1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/cloudresourcemanager1_beta1/Cargo.toml b/gen/cloudresourcemanager1_beta1/Cargo.toml index ad73e2601a..649dc21428 100644 --- a/gen/cloudresourcemanager1_beta1/Cargo.toml +++ b/gen/cloudresourcemanager1_beta1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/compute1-cli/Cargo.toml b/gen/compute1-cli/Cargo.toml index 97feb1a3a6..9f63c1d174 100644 --- a/gen/compute1-cli/Cargo.toml +++ b/gen/compute1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "compute1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/compute1-cli/src/cmn.rs b/gen/compute1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/compute1-cli/src/cmn.rs +++ b/gen/compute1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/compute1/Cargo.toml b/gen/compute1/Cargo.toml index d02bcb33e3..04b0e4f03f 100644 --- a/gen/compute1/Cargo.toml +++ b/gen/compute1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/container1_beta1-cli/Cargo.toml b/gen/container1_beta1-cli/Cargo.toml index 7580093bc8..fc044a393b 100644 --- a/gen/container1_beta1-cli/Cargo.toml +++ b/gen/container1_beta1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "container1-beta1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/container1_beta1-cli/src/cmn.rs b/gen/container1_beta1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/container1_beta1-cli/src/cmn.rs +++ b/gen/container1_beta1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/container1_beta1/Cargo.toml b/gen/container1_beta1/Cargo.toml index b325924672..bc7d13f14a 100644 --- a/gen/container1_beta1/Cargo.toml +++ b/gen/container1_beta1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/content2-cli/Cargo.toml b/gen/content2-cli/Cargo.toml index 214a96732a..6d93de1438 100644 --- a/gen/content2-cli/Cargo.toml +++ b/gen/content2-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "content2" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/content2-cli/src/cmn.rs b/gen/content2-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/content2-cli/src/cmn.rs +++ b/gen/content2-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/content2/Cargo.toml b/gen/content2/Cargo.toml index f95041bd72..c653b3ebf2 100644 --- a/gen/content2/Cargo.toml +++ b/gen/content2/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/coordinate1-cli/Cargo.toml b/gen/coordinate1-cli/Cargo.toml index b439ed1d41..8440d68928 100644 --- a/gen/coordinate1-cli/Cargo.toml +++ b/gen/coordinate1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "coordinate1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/coordinate1-cli/src/cmn.rs b/gen/coordinate1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/coordinate1-cli/src/cmn.rs +++ b/gen/coordinate1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/coordinate1/Cargo.toml b/gen/coordinate1/Cargo.toml index 739cab2f20..f0d396f928 100644 --- a/gen/coordinate1/Cargo.toml +++ b/gen/coordinate1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/customsearch1-cli/Cargo.toml b/gen/customsearch1-cli/Cargo.toml index 76d6acdc22..2dcc687493 100644 --- a/gen/customsearch1-cli/Cargo.toml +++ b/gen/customsearch1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "customsearch1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/customsearch1-cli/src/cmn.rs b/gen/customsearch1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/customsearch1-cli/src/cmn.rs +++ b/gen/customsearch1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/customsearch1/Cargo.toml b/gen/customsearch1/Cargo.toml index 067addf9d2..f009c31b57 100644 --- a/gen/customsearch1/Cargo.toml +++ b/gen/customsearch1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/datastore1_beta2-cli/Cargo.toml b/gen/datastore1_beta2-cli/Cargo.toml index 8b188973ed..877f9d99f5 100644 --- a/gen/datastore1_beta2-cli/Cargo.toml +++ b/gen/datastore1_beta2-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "datastore1-beta2" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/datastore1_beta2-cli/src/cmn.rs b/gen/datastore1_beta2-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/datastore1_beta2-cli/src/cmn.rs +++ b/gen/datastore1_beta2-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/datastore1_beta2/Cargo.toml b/gen/datastore1_beta2/Cargo.toml index f366718e18..fbe5ccd768 100644 --- a/gen/datastore1_beta2/Cargo.toml +++ b/gen/datastore1_beta2/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/deploymentmanager2_beta2-cli/Cargo.toml b/gen/deploymentmanager2_beta2-cli/Cargo.toml index 74fd063191..cbb7cfa1fc 100644 --- a/gen/deploymentmanager2_beta2-cli/Cargo.toml +++ b/gen/deploymentmanager2_beta2-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "deploymentmanager2-beta2" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/deploymentmanager2_beta2-cli/src/cmn.rs b/gen/deploymentmanager2_beta2-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/deploymentmanager2_beta2-cli/src/cmn.rs +++ b/gen/deploymentmanager2_beta2-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/deploymentmanager2_beta2/Cargo.toml b/gen/deploymentmanager2_beta2/Cargo.toml index 459e886fec..cd467b50f1 100644 --- a/gen/deploymentmanager2_beta2/Cargo.toml +++ b/gen/deploymentmanager2_beta2/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/dfareporting2d1-cli/Cargo.toml b/gen/dfareporting2d1-cli/Cargo.toml index 7f7d5d0cb8..3b5d0acaf7 100644 --- a/gen/dfareporting2d1-cli/Cargo.toml +++ b/gen/dfareporting2d1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "dfareporting2d1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/dfareporting2d1-cli/src/cmn.rs b/gen/dfareporting2d1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/dfareporting2d1-cli/src/cmn.rs +++ b/gen/dfareporting2d1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/dfareporting2d1/Cargo.toml b/gen/dfareporting2d1/Cargo.toml index 8dd45153e3..df505b84cf 100644 --- a/gen/dfareporting2d1/Cargo.toml +++ b/gen/dfareporting2d1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/discovery1-cli/Cargo.toml b/gen/discovery1-cli/Cargo.toml index 2db4ded1f4..80593f875e 100644 --- a/gen/discovery1-cli/Cargo.toml +++ b/gen/discovery1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "discovery1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/discovery1-cli/src/cmn.rs b/gen/discovery1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/discovery1-cli/src/cmn.rs +++ b/gen/discovery1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/discovery1/Cargo.toml b/gen/discovery1/Cargo.toml index fd16d9a09e..167d85e855 100644 --- a/gen/discovery1/Cargo.toml +++ b/gen/discovery1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/dns1-cli/Cargo.toml b/gen/dns1-cli/Cargo.toml index 84c46785b3..d1d7c99c8b 100644 --- a/gen/dns1-cli/Cargo.toml +++ b/gen/dns1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "dns1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/dns1-cli/src/cmn.rs b/gen/dns1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/dns1-cli/src/cmn.rs +++ b/gen/dns1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/dns1/Cargo.toml b/gen/dns1/Cargo.toml index 6c3b324e8b..8f13f5defe 100644 --- a/gen/dns1/Cargo.toml +++ b/gen/dns1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/doubleclickbidmanager1-cli/Cargo.toml b/gen/doubleclickbidmanager1-cli/Cargo.toml index 29542cadc7..85aef51598 100644 --- a/gen/doubleclickbidmanager1-cli/Cargo.toml +++ b/gen/doubleclickbidmanager1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "doubleclickbidmanager1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/doubleclickbidmanager1-cli/src/cmn.rs b/gen/doubleclickbidmanager1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/doubleclickbidmanager1-cli/src/cmn.rs +++ b/gen/doubleclickbidmanager1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/doubleclickbidmanager1/Cargo.toml b/gen/doubleclickbidmanager1/Cargo.toml index 4f7300b8db..990b67b679 100644 --- a/gen/doubleclickbidmanager1/Cargo.toml +++ b/gen/doubleclickbidmanager1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/doubleclicksearch2-cli/Cargo.toml b/gen/doubleclicksearch2-cli/Cargo.toml index e3399c5012..2ed174f930 100644 --- a/gen/doubleclicksearch2-cli/Cargo.toml +++ b/gen/doubleclicksearch2-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "doubleclicksearch2" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/doubleclicksearch2-cli/src/cmn.rs b/gen/doubleclicksearch2-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/doubleclicksearch2-cli/src/cmn.rs +++ b/gen/doubleclicksearch2-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/doubleclicksearch2/Cargo.toml b/gen/doubleclicksearch2/Cargo.toml index aed73a9954..fdd8018c86 100644 --- a/gen/doubleclicksearch2/Cargo.toml +++ b/gen/doubleclicksearch2/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/drive2-cli/Cargo.toml b/gen/drive2-cli/Cargo.toml index bae8d6693f..d2ebd08ccf 100644 --- a/gen/drive2-cli/Cargo.toml +++ b/gen/drive2-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "drive2" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/drive2-cli/src/cmn.rs b/gen/drive2-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/drive2-cli/src/cmn.rs +++ b/gen/drive2-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/drive2/Cargo.toml b/gen/drive2/Cargo.toml index ed0e08e921..989f6a444d 100644 --- a/gen/drive2/Cargo.toml +++ b/gen/drive2/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/fitness1-cli/Cargo.toml b/gen/fitness1-cli/Cargo.toml index 2ba25eb8b1..9630cb50f5 100644 --- a/gen/fitness1-cli/Cargo.toml +++ b/gen/fitness1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "fitness1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/fitness1-cli/src/cmn.rs b/gen/fitness1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/fitness1-cli/src/cmn.rs +++ b/gen/fitness1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/fitness1/Cargo.toml b/gen/fitness1/Cargo.toml index 57f95210a6..6b0a795a61 100644 --- a/gen/fitness1/Cargo.toml +++ b/gen/fitness1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/freebase1-cli/Cargo.toml b/gen/freebase1-cli/Cargo.toml index 03cabc6361..6c75cd4f0d 100644 --- a/gen/freebase1-cli/Cargo.toml +++ b/gen/freebase1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "freebase1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/freebase1-cli/src/cmn.rs b/gen/freebase1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/freebase1-cli/src/cmn.rs +++ b/gen/freebase1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/freebase1/Cargo.toml b/gen/freebase1/Cargo.toml index d7966faa60..3e9bb02909 100644 --- a/gen/freebase1/Cargo.toml +++ b/gen/freebase1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/freebase1_sandbox-cli/Cargo.toml b/gen/freebase1_sandbox-cli/Cargo.toml index e96f38d24a..287f4e1386 100644 --- a/gen/freebase1_sandbox-cli/Cargo.toml +++ b/gen/freebase1_sandbox-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "freebase1-sandbox" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/freebase1_sandbox-cli/src/cmn.rs b/gen/freebase1_sandbox-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/freebase1_sandbox-cli/src/cmn.rs +++ b/gen/freebase1_sandbox-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/freebase1_sandbox/Cargo.toml b/gen/freebase1_sandbox/Cargo.toml index 66e6c3c076..a8e6ad7d3d 100644 --- a/gen/freebase1_sandbox/Cargo.toml +++ b/gen/freebase1_sandbox/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/fusiontables2-cli/Cargo.toml b/gen/fusiontables2-cli/Cargo.toml index 593b24b090..9694b5e059 100644 --- a/gen/fusiontables2-cli/Cargo.toml +++ b/gen/fusiontables2-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "fusiontables2" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/fusiontables2-cli/src/cmn.rs b/gen/fusiontables2-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/fusiontables2-cli/src/cmn.rs +++ b/gen/fusiontables2-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/fusiontables2/Cargo.toml b/gen/fusiontables2/Cargo.toml index 42ebecdd31..2a94923916 100644 --- a/gen/fusiontables2/Cargo.toml +++ b/gen/fusiontables2/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/games1-cli/Cargo.toml b/gen/games1-cli/Cargo.toml index de404e4d20..688cb5bf38 100644 --- a/gen/games1-cli/Cargo.toml +++ b/gen/games1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "games1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/games1-cli/src/cmn.rs b/gen/games1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/games1-cli/src/cmn.rs +++ b/gen/games1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/games1/Cargo.toml b/gen/games1/Cargo.toml index a7d1704e71..5ac61529fe 100644 --- a/gen/games1/Cargo.toml +++ b/gen/games1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/gamesconfiguration1_configuration-cli/Cargo.toml b/gen/gamesconfiguration1_configuration-cli/Cargo.toml index 740404a8cc..f66b418a4a 100644 --- a/gen/gamesconfiguration1_configuration-cli/Cargo.toml +++ b/gen/gamesconfiguration1_configuration-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "gamesconfiguration1-configuration" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/gamesconfiguration1_configuration-cli/src/cmn.rs b/gen/gamesconfiguration1_configuration-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/gamesconfiguration1_configuration-cli/src/cmn.rs +++ b/gen/gamesconfiguration1_configuration-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/gamesconfiguration1_configuration/Cargo.toml b/gen/gamesconfiguration1_configuration/Cargo.toml index 14c1eac944..7a7808bb67 100644 --- a/gen/gamesconfiguration1_configuration/Cargo.toml +++ b/gen/gamesconfiguration1_configuration/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/gamesmanagement1_management-cli/Cargo.toml b/gen/gamesmanagement1_management-cli/Cargo.toml index df1a186a28..36e6bb2411 100644 --- a/gen/gamesmanagement1_management-cli/Cargo.toml +++ b/gen/gamesmanagement1_management-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "gamesmanagement1-management" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/gamesmanagement1_management-cli/src/cmn.rs b/gen/gamesmanagement1_management-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/gamesmanagement1_management-cli/src/cmn.rs +++ b/gen/gamesmanagement1_management-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/gamesmanagement1_management/Cargo.toml b/gen/gamesmanagement1_management/Cargo.toml index 7720e49537..8d803dcc72 100644 --- a/gen/gamesmanagement1_management/Cargo.toml +++ b/gen/gamesmanagement1_management/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/gan1_beta1-cli/Cargo.toml b/gen/gan1_beta1-cli/Cargo.toml index 495343f692..f69f1f2a7b 100644 --- a/gen/gan1_beta1-cli/Cargo.toml +++ b/gen/gan1_beta1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "gan1-beta1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/gan1_beta1-cli/src/cmn.rs b/gen/gan1_beta1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/gan1_beta1-cli/src/cmn.rs +++ b/gen/gan1_beta1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/gan1_beta1/Cargo.toml b/gen/gan1_beta1/Cargo.toml index c181715216..e78a314237 100644 --- a/gen/gan1_beta1/Cargo.toml +++ b/gen/gan1_beta1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/genomics1-cli/Cargo.toml b/gen/genomics1-cli/Cargo.toml index d2c5b22145..1320a9da86 100644 --- a/gen/genomics1-cli/Cargo.toml +++ b/gen/genomics1-cli/Cargo.toml @@ -18,8 +18,8 @@ name = "genomics1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/genomics1-cli/src/cmn.rs b/gen/genomics1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/genomics1-cli/src/cmn.rs +++ b/gen/genomics1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/genomics1/Cargo.toml b/gen/genomics1/Cargo.toml index 79cf25324e..1d81a77b70 100644 --- a/gen/genomics1/Cargo.toml +++ b/gen/genomics1/Cargo.toml @@ -17,8 +17,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/gmail1-cli/Cargo.toml b/gen/gmail1-cli/Cargo.toml index b5674c8b03..24b54c0814 100644 --- a/gen/gmail1-cli/Cargo.toml +++ b/gen/gmail1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "gmail1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/gmail1-cli/src/cmn.rs b/gen/gmail1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/gmail1-cli/src/cmn.rs +++ b/gen/gmail1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/gmail1/Cargo.toml b/gen/gmail1/Cargo.toml index a4a825bf16..1352fa1826 100644 --- a/gen/gmail1/Cargo.toml +++ b/gen/gmail1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/groupsmigration1-cli/Cargo.toml b/gen/groupsmigration1-cli/Cargo.toml index 6e856dcf51..28870171c3 100644 --- a/gen/groupsmigration1-cli/Cargo.toml +++ b/gen/groupsmigration1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "groupsmigration1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/groupsmigration1-cli/src/cmn.rs b/gen/groupsmigration1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/groupsmigration1-cli/src/cmn.rs +++ b/gen/groupsmigration1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/groupsmigration1/Cargo.toml b/gen/groupsmigration1/Cargo.toml index f166730f3d..ecf775ed36 100644 --- a/gen/groupsmigration1/Cargo.toml +++ b/gen/groupsmigration1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/groupssettings1-cli/Cargo.toml b/gen/groupssettings1-cli/Cargo.toml index a88fc91c15..c69908f26b 100644 --- a/gen/groupssettings1-cli/Cargo.toml +++ b/gen/groupssettings1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "groupssettings1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/groupssettings1-cli/src/cmn.rs b/gen/groupssettings1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/groupssettings1-cli/src/cmn.rs +++ b/gen/groupssettings1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/groupssettings1/Cargo.toml b/gen/groupssettings1/Cargo.toml index 4b2d1915e9..713e3d16fd 100644 --- a/gen/groupssettings1/Cargo.toml +++ b/gen/groupssettings1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/identitytoolkit3-cli/Cargo.toml b/gen/identitytoolkit3-cli/Cargo.toml index cb454d6305..2de142a8b9 100644 --- a/gen/identitytoolkit3-cli/Cargo.toml +++ b/gen/identitytoolkit3-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "identitytoolkit3" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/identitytoolkit3-cli/src/cmn.rs b/gen/identitytoolkit3-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/identitytoolkit3-cli/src/cmn.rs +++ b/gen/identitytoolkit3-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/identitytoolkit3/Cargo.toml b/gen/identitytoolkit3/Cargo.toml index 495d62f9a7..b2622ecb28 100644 --- a/gen/identitytoolkit3/Cargo.toml +++ b/gen/identitytoolkit3/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/licensing1-cli/Cargo.toml b/gen/licensing1-cli/Cargo.toml index a7d55c82f7..4121253bd9 100644 --- a/gen/licensing1-cli/Cargo.toml +++ b/gen/licensing1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "licensing1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/licensing1-cli/src/cmn.rs b/gen/licensing1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/licensing1-cli/src/cmn.rs +++ b/gen/licensing1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/licensing1/Cargo.toml b/gen/licensing1/Cargo.toml index b6d5a40377..baa47d3af7 100644 --- a/gen/licensing1/Cargo.toml +++ b/gen/licensing1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/logging1_beta3-cli/Cargo.toml b/gen/logging1_beta3-cli/Cargo.toml index 66bdfa27a9..7507d30071 100644 --- a/gen/logging1_beta3-cli/Cargo.toml +++ b/gen/logging1_beta3-cli/Cargo.toml @@ -18,8 +18,8 @@ name = "logging1-beta3" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/logging1_beta3-cli/src/cmn.rs b/gen/logging1_beta3-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/logging1_beta3-cli/src/cmn.rs +++ b/gen/logging1_beta3-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/logging1_beta3/Cargo.toml b/gen/logging1_beta3/Cargo.toml index 1cf5555dff..5862d0d64e 100644 --- a/gen/logging1_beta3/Cargo.toml +++ b/gen/logging1_beta3/Cargo.toml @@ -17,8 +17,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/manager1_beta2-cli/Cargo.toml b/gen/manager1_beta2-cli/Cargo.toml index 01a7b94790..808e8e2dd8 100644 --- a/gen/manager1_beta2-cli/Cargo.toml +++ b/gen/manager1_beta2-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "manager1-beta2" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/manager1_beta2-cli/src/cmn.rs b/gen/manager1_beta2-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/manager1_beta2-cli/src/cmn.rs +++ b/gen/manager1_beta2-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/manager1_beta2/Cargo.toml b/gen/manager1_beta2/Cargo.toml index 5bcd3e4411..8020629ef9 100644 --- a/gen/manager1_beta2/Cargo.toml +++ b/gen/manager1_beta2/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/mapsengine1-cli/Cargo.toml b/gen/mapsengine1-cli/Cargo.toml index 9f369bfbcf..d228d60817 100644 --- a/gen/mapsengine1-cli/Cargo.toml +++ b/gen/mapsengine1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "mapsengine1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/mapsengine1-cli/src/cmn.rs b/gen/mapsengine1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/mapsengine1-cli/src/cmn.rs +++ b/gen/mapsengine1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/mapsengine1/Cargo.toml b/gen/mapsengine1/Cargo.toml index 7ef1d4166d..2844deeaa7 100644 --- a/gen/mapsengine1/Cargo.toml +++ b/gen/mapsengine1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/mirror1-cli/Cargo.toml b/gen/mirror1-cli/Cargo.toml index 6d322e42bf..20e7cee6fc 100644 --- a/gen/mirror1-cli/Cargo.toml +++ b/gen/mirror1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "mirror1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/mirror1-cli/src/cmn.rs b/gen/mirror1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/mirror1-cli/src/cmn.rs +++ b/gen/mirror1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/mirror1/Cargo.toml b/gen/mirror1/Cargo.toml index a10094c549..f13b4e5b1d 100644 --- a/gen/mirror1/Cargo.toml +++ b/gen/mirror1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/oauth2_v2-cli/Cargo.toml b/gen/oauth2_v2-cli/Cargo.toml index beda58487b..c2ce1f0822 100644 --- a/gen/oauth2_v2-cli/Cargo.toml +++ b/gen/oauth2_v2-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "oauth2-v2" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/oauth2_v2-cli/src/cmn.rs b/gen/oauth2_v2-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/oauth2_v2-cli/src/cmn.rs +++ b/gen/oauth2_v2-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/oauth2_v2/Cargo.toml b/gen/oauth2_v2/Cargo.toml index a7aa92c6fb..5fa3334c97 100644 --- a/gen/oauth2_v2/Cargo.toml +++ b/gen/oauth2_v2/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/pagespeedonline2-cli/Cargo.toml b/gen/pagespeedonline2-cli/Cargo.toml index b63d6960fa..5defc1f9e1 100644 --- a/gen/pagespeedonline2-cli/Cargo.toml +++ b/gen/pagespeedonline2-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "pagespeedonline2" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/pagespeedonline2-cli/src/cmn.rs b/gen/pagespeedonline2-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/pagespeedonline2-cli/src/cmn.rs +++ b/gen/pagespeedonline2-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/pagespeedonline2/Cargo.toml b/gen/pagespeedonline2/Cargo.toml index aa651983e3..6de9e32629 100644 --- a/gen/pagespeedonline2/Cargo.toml +++ b/gen/pagespeedonline2/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/plus1-cli/Cargo.toml b/gen/plus1-cli/Cargo.toml index d931954425..84b99e400a 100644 --- a/gen/plus1-cli/Cargo.toml +++ b/gen/plus1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "plus1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/plus1-cli/src/cmn.rs b/gen/plus1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/plus1-cli/src/cmn.rs +++ b/gen/plus1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/plus1/Cargo.toml b/gen/plus1/Cargo.toml index 6a0cab78fa..bd4b5601d0 100644 --- a/gen/plus1/Cargo.toml +++ b/gen/plus1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/plusdomains1-cli/Cargo.toml b/gen/plusdomains1-cli/Cargo.toml index f7f0cb0014..0476a13d29 100644 --- a/gen/plusdomains1-cli/Cargo.toml +++ b/gen/plusdomains1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "plusdomains1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/plusdomains1-cli/src/cmn.rs b/gen/plusdomains1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/plusdomains1-cli/src/cmn.rs +++ b/gen/plusdomains1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/plusdomains1/Cargo.toml b/gen/plusdomains1/Cargo.toml index a025c7053f..3035d9ebe1 100644 --- a/gen/plusdomains1/Cargo.toml +++ b/gen/plusdomains1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/prediction1d6-cli/Cargo.toml b/gen/prediction1d6-cli/Cargo.toml index f19371d182..24da30bbef 100644 --- a/gen/prediction1d6-cli/Cargo.toml +++ b/gen/prediction1d6-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "prediction1d6" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/prediction1d6-cli/src/cmn.rs b/gen/prediction1d6-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/prediction1d6-cli/src/cmn.rs +++ b/gen/prediction1d6-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/prediction1d6/Cargo.toml b/gen/prediction1d6/Cargo.toml index a4c547bf49..20234d4b0c 100644 --- a/gen/prediction1d6/Cargo.toml +++ b/gen/prediction1d6/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/pubsub1_beta2-cli/Cargo.toml b/gen/pubsub1_beta2-cli/Cargo.toml index a9b9ceea11..06634d8f10 100644 --- a/gen/pubsub1_beta2-cli/Cargo.toml +++ b/gen/pubsub1_beta2-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "pubsub1-beta2" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/pubsub1_beta2-cli/src/cmn.rs b/gen/pubsub1_beta2-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/pubsub1_beta2-cli/src/cmn.rs +++ b/gen/pubsub1_beta2-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/pubsub1_beta2/Cargo.toml b/gen/pubsub1_beta2/Cargo.toml index c4ca046505..033b258c1e 100644 --- a/gen/pubsub1_beta2/Cargo.toml +++ b/gen/pubsub1_beta2/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/qpxexpress1-cli/Cargo.toml b/gen/qpxexpress1-cli/Cargo.toml index 975623e757..d31cd7deec 100644 --- a/gen/qpxexpress1-cli/Cargo.toml +++ b/gen/qpxexpress1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "qpxexpress1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/qpxexpress1-cli/src/cmn.rs b/gen/qpxexpress1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/qpxexpress1-cli/src/cmn.rs +++ b/gen/qpxexpress1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/qpxexpress1/Cargo.toml b/gen/qpxexpress1/Cargo.toml index ec5dc44f52..fac578fc7f 100644 --- a/gen/qpxexpress1/Cargo.toml +++ b/gen/qpxexpress1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/replicapool1_beta2-cli/Cargo.toml b/gen/replicapool1_beta2-cli/Cargo.toml index ad00dc118b..0b9038c83a 100644 --- a/gen/replicapool1_beta2-cli/Cargo.toml +++ b/gen/replicapool1_beta2-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "replicapool1-beta2" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/replicapool1_beta2-cli/src/cmn.rs b/gen/replicapool1_beta2-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/replicapool1_beta2-cli/src/cmn.rs +++ b/gen/replicapool1_beta2-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/replicapool1_beta2/Cargo.toml b/gen/replicapool1_beta2/Cargo.toml index 5952e9914e..afab783824 100644 --- a/gen/replicapool1_beta2/Cargo.toml +++ b/gen/replicapool1_beta2/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/replicapoolupdater1_beta1-cli/Cargo.toml b/gen/replicapoolupdater1_beta1-cli/Cargo.toml index 2c9dd374d3..e18da1821d 100644 --- a/gen/replicapoolupdater1_beta1-cli/Cargo.toml +++ b/gen/replicapoolupdater1_beta1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "replicapoolupdater1-beta1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/replicapoolupdater1_beta1-cli/src/cmn.rs b/gen/replicapoolupdater1_beta1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/replicapoolupdater1_beta1-cli/src/cmn.rs +++ b/gen/replicapoolupdater1_beta1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/replicapoolupdater1_beta1/Cargo.toml b/gen/replicapoolupdater1_beta1/Cargo.toml index 3592a0f19d..28710eeb6a 100644 --- a/gen/replicapoolupdater1_beta1/Cargo.toml +++ b/gen/replicapoolupdater1_beta1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/reseller1_sandbox-cli/Cargo.toml b/gen/reseller1_sandbox-cli/Cargo.toml index cc054ce87b..51b9aedc0c 100644 --- a/gen/reseller1_sandbox-cli/Cargo.toml +++ b/gen/reseller1_sandbox-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "reseller1-sandbox" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/reseller1_sandbox-cli/src/cmn.rs b/gen/reseller1_sandbox-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/reseller1_sandbox-cli/src/cmn.rs +++ b/gen/reseller1_sandbox-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/reseller1_sandbox/Cargo.toml b/gen/reseller1_sandbox/Cargo.toml index 9d8b35120c..ceae453019 100644 --- a/gen/reseller1_sandbox/Cargo.toml +++ b/gen/reseller1_sandbox/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/resourceviews1_beta2-cli/Cargo.toml b/gen/resourceviews1_beta2-cli/Cargo.toml index 1b99bfa880..82df69495e 100644 --- a/gen/resourceviews1_beta2-cli/Cargo.toml +++ b/gen/resourceviews1_beta2-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "resourceviews1-beta2" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/resourceviews1_beta2-cli/src/cmn.rs b/gen/resourceviews1_beta2-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/resourceviews1_beta2-cli/src/cmn.rs +++ b/gen/resourceviews1_beta2-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/resourceviews1_beta2/Cargo.toml b/gen/resourceviews1_beta2/Cargo.toml index 78cd85f9d3..5c35cdadee 100644 --- a/gen/resourceviews1_beta2/Cargo.toml +++ b/gen/resourceviews1_beta2/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/siteverification1-cli/Cargo.toml b/gen/siteverification1-cli/Cargo.toml index 90d5924587..bc90e55651 100644 --- a/gen/siteverification1-cli/Cargo.toml +++ b/gen/siteverification1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "siteverification1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/siteverification1-cli/src/cmn.rs b/gen/siteverification1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/siteverification1-cli/src/cmn.rs +++ b/gen/siteverification1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/siteverification1/Cargo.toml b/gen/siteverification1/Cargo.toml index ab0760afaf..ba45956bba 100644 --- a/gen/siteverification1/Cargo.toml +++ b/gen/siteverification1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/spectrum1_explorer-cli/Cargo.toml b/gen/spectrum1_explorer-cli/Cargo.toml index 4201a03404..dd354e60ff 100644 --- a/gen/spectrum1_explorer-cli/Cargo.toml +++ b/gen/spectrum1_explorer-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "spectrum1-explorer" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/spectrum1_explorer-cli/src/cmn.rs b/gen/spectrum1_explorer-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/spectrum1_explorer-cli/src/cmn.rs +++ b/gen/spectrum1_explorer-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/spectrum1_explorer/Cargo.toml b/gen/spectrum1_explorer/Cargo.toml index 533ca8544a..0e551411fc 100644 --- a/gen/spectrum1_explorer/Cargo.toml +++ b/gen/spectrum1_explorer/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/sqladmin1_beta4-cli/Cargo.toml b/gen/sqladmin1_beta4-cli/Cargo.toml index f572f0b47c..f441932dfa 100644 --- a/gen/sqladmin1_beta4-cli/Cargo.toml +++ b/gen/sqladmin1_beta4-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "sqladmin1-beta4" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/sqladmin1_beta4-cli/src/cmn.rs b/gen/sqladmin1_beta4-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/sqladmin1_beta4-cli/src/cmn.rs +++ b/gen/sqladmin1_beta4-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/sqladmin1_beta4/Cargo.toml b/gen/sqladmin1_beta4/Cargo.toml index 136c626a13..c353f42ced 100644 --- a/gen/sqladmin1_beta4/Cargo.toml +++ b/gen/sqladmin1_beta4/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/storage1-cli/Cargo.toml b/gen/storage1-cli/Cargo.toml index 238b61ba7f..626c1f8ddf 100644 --- a/gen/storage1-cli/Cargo.toml +++ b/gen/storage1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "storage1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/storage1-cli/src/cmn.rs b/gen/storage1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/storage1-cli/src/cmn.rs +++ b/gen/storage1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/storage1/Cargo.toml b/gen/storage1/Cargo.toml index 6bf3871c3b..28c9bdc6da 100644 --- a/gen/storage1/Cargo.toml +++ b/gen/storage1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/tagmanager1-cli/Cargo.toml b/gen/tagmanager1-cli/Cargo.toml index 7e3865feff..9615c85421 100644 --- a/gen/tagmanager1-cli/Cargo.toml +++ b/gen/tagmanager1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "tagmanager1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/tagmanager1-cli/src/cmn.rs b/gen/tagmanager1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/tagmanager1-cli/src/cmn.rs +++ b/gen/tagmanager1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/tagmanager1/Cargo.toml b/gen/tagmanager1/Cargo.toml index 0944a4c2d6..9eb0300f3a 100644 --- a/gen/tagmanager1/Cargo.toml +++ b/gen/tagmanager1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/taskqueue1_beta2-cli/Cargo.toml b/gen/taskqueue1_beta2-cli/Cargo.toml index 01a8431f34..beb5a819fb 100644 --- a/gen/taskqueue1_beta2-cli/Cargo.toml +++ b/gen/taskqueue1_beta2-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "taskqueue1-beta2" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/taskqueue1_beta2-cli/src/cmn.rs b/gen/taskqueue1_beta2-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/taskqueue1_beta2-cli/src/cmn.rs +++ b/gen/taskqueue1_beta2-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/taskqueue1_beta2/Cargo.toml b/gen/taskqueue1_beta2/Cargo.toml index 7f8bfd2810..7818eee43a 100644 --- a/gen/taskqueue1_beta2/Cargo.toml +++ b/gen/taskqueue1_beta2/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/tasks1-cli/Cargo.toml b/gen/tasks1-cli/Cargo.toml index c84cb33102..216b1f3643 100644 --- a/gen/tasks1-cli/Cargo.toml +++ b/gen/tasks1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "tasks1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/tasks1-cli/src/cmn.rs b/gen/tasks1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/tasks1-cli/src/cmn.rs +++ b/gen/tasks1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/tasks1/Cargo.toml b/gen/tasks1/Cargo.toml index 0c2a2dedd6..6a27d4ac9a 100644 --- a/gen/tasks1/Cargo.toml +++ b/gen/tasks1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/translate2-cli/Cargo.toml b/gen/translate2-cli/Cargo.toml index d36eb4caf7..484ee48258 100644 --- a/gen/translate2-cli/Cargo.toml +++ b/gen/translate2-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "translate2" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/translate2-cli/src/cmn.rs b/gen/translate2-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/translate2-cli/src/cmn.rs +++ b/gen/translate2-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/translate2/Cargo.toml b/gen/translate2/Cargo.toml index 2b6ee2a0f2..e1761163be 100644 --- a/gen/translate2/Cargo.toml +++ b/gen/translate2/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/urlshortener1-cli/Cargo.toml b/gen/urlshortener1-cli/Cargo.toml index 26687f2aa8..8787197ca6 100644 --- a/gen/urlshortener1-cli/Cargo.toml +++ b/gen/urlshortener1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "urlshortener1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/urlshortener1-cli/src/cmn.rs b/gen/urlshortener1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/urlshortener1-cli/src/cmn.rs +++ b/gen/urlshortener1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/urlshortener1/Cargo.toml b/gen/urlshortener1/Cargo.toml index a7464d601d..dcefcc36d5 100644 --- a/gen/urlshortener1/Cargo.toml +++ b/gen/urlshortener1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/webfonts1-cli/Cargo.toml b/gen/webfonts1-cli/Cargo.toml index c1b0827b8c..6003229148 100644 --- a/gen/webfonts1-cli/Cargo.toml +++ b/gen/webfonts1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "webfonts1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/webfonts1-cli/src/cmn.rs b/gen/webfonts1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/webfonts1-cli/src/cmn.rs +++ b/gen/webfonts1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/webfonts1/Cargo.toml b/gen/webfonts1/Cargo.toml index 231549050b..b5123067de 100644 --- a/gen/webfonts1/Cargo.toml +++ b/gen/webfonts1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/webmasters3-cli/Cargo.toml b/gen/webmasters3-cli/Cargo.toml index 7e3cf40589..01ba7fd8b3 100644 --- a/gen/webmasters3-cli/Cargo.toml +++ b/gen/webmasters3-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "webmasters3" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/webmasters3-cli/src/cmn.rs b/gen/webmasters3-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/webmasters3-cli/src/cmn.rs +++ b/gen/webmasters3-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/webmasters3/Cargo.toml b/gen/webmasters3/Cargo.toml index 63cb826be0..aa3cb46917 100644 --- a/gen/webmasters3/Cargo.toml +++ b/gen/webmasters3/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/youtube3-cli/Cargo.toml b/gen/youtube3-cli/Cargo.toml index 5fc7d0e33e..05bf6dd0c4 100644 --- a/gen/youtube3-cli/Cargo.toml +++ b/gen/youtube3-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "youtube3" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/youtube3-cli/src/cmn.rs b/gen/youtube3-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/youtube3-cli/src/cmn.rs +++ b/gen/youtube3-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/youtube3/cargo.toml b/gen/youtube3/cargo.toml index 59b7dba3ed..263f7454e5 100644 --- a/gen/youtube3/cargo.toml +++ b/gen/youtube3/cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*" diff --git a/gen/youtubeanalytics1-cli/Cargo.toml b/gen/youtubeanalytics1-cli/Cargo.toml index 4c128bf0ae..4d2c2fbe8d 100644 --- a/gen/youtubeanalytics1-cli/Cargo.toml +++ b/gen/youtubeanalytics1-cli/Cargo.toml @@ -19,8 +19,8 @@ name = "youtubeanalytics1" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" strsim = "*" yup-hyper-mock = ">=1.0.0" diff --git a/gen/youtubeanalytics1-cli/src/cmn.rs b/gen/youtubeanalytics1-cli/src/cmn.rs index b65c8f7c9f..8358f156fa 100644 --- a/gen/youtubeanalytics1-cli/src/cmn.rs +++ b/gen/youtubeanalytics1-cli/src/cmn.rs @@ -120,7 +120,7 @@ pub struct FieldCursor(Vec); impl ToString for FieldCursor { fn to_string(&self) -> String { - self.0.connect(".") + self.0.join(".") } } @@ -237,15 +237,15 @@ impl FieldCursor { } } - pub fn set_json_value(&self, mut object: &mut Value, + pub fn set_json_value(&self, mut object: &mut Value, value: &str, type_info: JsonTypeInfo, - err: &mut InvalidOptionsError, + err: &mut InvalidOptionsError, orig_cursor: &FieldCursor) { assert!(self.0.len() > 0); for field in &self.0[..self.0.len()-1] { let tmp = object; - object = + object = match *tmp { Value::Object(ref mut mapping) => { mapping.entry(field.to_owned()).or_insert( @@ -259,19 +259,19 @@ impl FieldCursor { match *object { Value::Object(ref mut mapping) => { let field = &self.0[self.0.len()-1]; - let to_jval = - |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| + let to_jval = + |value: &str, jtype: JsonType, err: &mut InvalidOptionsError| -> Value { match jtype { - JsonType::Boolean => + JsonType::Boolean => Value::Bool(arg_from_str(value, err, &field, "boolean")), - JsonType::Int => + JsonType::Int => Value::I64(arg_from_str(value, err, &field, "int")), - JsonType::Uint => + JsonType::Uint => Value::U64(arg_from_str(value, err, &field, "uint")), - JsonType::Float => + JsonType::Float => Value::F64(arg_from_str(value, err, &field, "float")), - JsonType::String => + JsonType::String => Value::String(value.to_owned()), } }; @@ -338,7 +338,7 @@ pub fn calltype_from_str(name: &str, valid_protocols: Vec, err: &mut Inv match UploadProtocol::from_str(name) { Ok(up) => up, Err(msg) => { - err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); + err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols)); UploadProtocol::Simple } }) @@ -376,8 +376,8 @@ pub fn writer_from_opts(arg: Option<&str>) -> Result, io::Error> { } -pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'a str, +pub fn arg_from_str<'a, T>(arg: &str, err: &mut InvalidOptionsError, + arg_name: &'a str, arg_type: &'a str) -> T where T: FromStr + Default, ::Err: fmt::Display { @@ -411,7 +411,7 @@ impl TokenStorage for JsonTokenStorage { match token { None => { match fs::remove_file(self.path(scope_hash)) { - Err(err) => + Err(err) => match err.kind() { io::ErrorKind::NotFound => Ok(()), _ => Err(json::Error::IoError(err)) @@ -424,7 +424,7 @@ impl TokenStorage for JsonTokenStorage { Ok(mut f) => { match json::to_writer_pretty(&mut f, &token) { Ok(_) => Ok(()), - Err(io_err) => Err(json::Error::IoError(io_err)), + Err(serde_err) => Err(serde_err), } }, Err(io_err) => Err(json::Error::IoError(io_err)) @@ -455,17 +455,17 @@ impl TokenStorage for JsonTokenStorage { #[derive(Debug)] pub enum ApplicationSecretError { DecoderError((String, json::Error)), - FormatError(String), + FormatError(String), } impl fmt::Display for ApplicationSecretError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}.", + => writeln!(f, "Could not decode file at '{}' with error: {}.", path, err), ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'.", + => writeln!(f, "'installed' field is unset in secret file at '{}'.", path), } } @@ -485,7 +485,7 @@ impl fmt::Display for ConfigurationError { match *self { ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) => writeln!(f, "Directory '{}' could not be created with error: {}.", dir, err), - ConfigurationError::DirectoryUnset + ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."), ConfigurationError::HomeExpansionFailed(ref dir) => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'.", dir), @@ -532,10 +532,10 @@ impl fmt::Display for FieldError { FieldError::TrailingFieldSep(ref field) => writeln!(f, "'{}': Single field separator may not be last character.", field), FieldError::Unknown(ref field, ref suggestion, ref value) => { - let suffix = + let suffix = match *suggestion { Some(ref s) => { - let kv = + let kv = match *value { Some(ref v) => format!("{}={}", s, v), None => s.clone(), @@ -546,7 +546,7 @@ impl fmt::Display for FieldError { }; writeln!(f, "Field '{}' does not exist.{}", field, suffix) }, - FieldError::Duplicate(ref cursor) + FieldError::Duplicate(ref cursor) => writeln!(f, "Value at '{}' was already set", cursor), FieldError::Empty => writeln!(f, "Field names must not be empty."), @@ -574,13 +574,13 @@ impl fmt::Display for CLIError { CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), CLIError::Input(ref err) => write!(f, "Input -> {}", err), CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) - => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.connect(", ")), - CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) + CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) + => writeln!(f, "'{}' is not a valid upload protocol. Choose from one of {}.", proto_name, valid_names.join(", ")), + CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}.", arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name, ref possible_values) => { - let mut suffix = + let mut suffix = match did_you_mean(param_name, &possible_values) { Some(v) => format!(" Did you mean '{}' ?", v), None => String::new(), @@ -634,7 +634,7 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) } - let expanded_config_dir = + let expanded_config_dir = if trdir.as_bytes()[0] == b'~' { match env::var("HOME").ok().or(env::var("UserProfile").ok()) { None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), @@ -657,8 +657,8 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, - secret_basename: &str, +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, json_console_secret: &str) -> Result { let secret_path = Path::new(dir).join(secret_basename); @@ -679,10 +679,13 @@ pub fn application_secret_from_directory(dir: &str, Err(cfe) => cfe, Ok(mut f) => { // Assure we convert 'ugly' json string into pretty one - let console_secret: ConsoleApplicationSecret + let console_secret: ConsoleApplicationSecret = json::from_str(json_console_secret).unwrap(); match json::to_writer_pretty(&mut f, &console_secret) { - Err(io_err) => io_err, + Err(serde_err) => match serde_err { + json::Error::IoError(err) => err, + _ => panic!("Unexpected serde error: {:#?}", serde_err) + }, Ok(_) => continue, } } @@ -693,15 +696,15 @@ pub fn application_secret_from_directory(dir: &str, }, Ok(mut f) => { match json::de::from_reader::<_, ConsoleApplicationSecret>(f) { - Err(json::Error::IoError(err)) => + Err(json::Error::IoError(err)) => return secret_io_error(err), - Err(json_err) => + Err(json_err) => return Err(CLIError::Configuration( ConfigurationError::Secret( ApplicationSecretError::DecoderError( (secret_str(), json_err) )))), - Ok(console_secret) => + Ok(console_secret) => match console_secret.installed { Some(secret) => return Ok(secret), None => return Err( @@ -715,4 +718,4 @@ pub fn application_secret_from_directory(dir: &str, } } unreachable!(); -} \ No newline at end of file +} diff --git a/gen/youtubeanalytics1/Cargo.toml b/gen/youtubeanalytics1/Cargo.toml index b6117eda4e..2f79b99880 100644 --- a/gen/youtubeanalytics1/Cargo.toml +++ b/gen/youtubeanalytics1/Cargo.toml @@ -18,8 +18,8 @@ build = "src/build.rs" [dependencies] hyper = ">= 0.6.8" mime = "0.1.0" -serde = ">= 0.5.0" -serde_json = "*" +serde = ">= 0.6.0" +serde_json = ">= 0.6.0" yup-oauth2 = "*" url = "*"