chore(code): updated to latest state

This commit is contained in:
Sebastian Thiel
2016-01-30 14:08:25 +01:00
parent 5cba22f0c6
commit 75076acf16
1164 changed files with 241839 additions and 123033 deletions

View File

@@ -20,7 +20,7 @@ use clap::{App, SubCommand, Arg};
mod cmn;
use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg,
use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg,
input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError, CallType, UploadProtocol,
calltype_from_str, remove_json_null_values, ComplexType, JsonType, JsonTypeInfo};
@@ -36,19 +36,19 @@ enum DoitError {
ApiError(api::Error),
}
struct Engine<'n, 'a> {
opt: ArgMatches<'n, 'a>,
struct Engine<'n> {
opt: ArgMatches<'n>,
hub: api::Coordinate<hyper::Client, Authenticator<DefaultAuthenticatorDelegate, JsonTokenStorage, hyper::Client>>,
gp: Vec<&'static str>,
gpm: Vec<(&'static str, &'static str)>,
}
impl<'n, 'a> Engine<'n, 'a> {
fn _custom_field_def_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
impl<'n> Engine<'n> {
fn _custom_field_def_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut call = self.hub.custom_field_def().list(opt.value_of("team-id").unwrap_or(""));
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
_ => {
@@ -61,7 +61,7 @@ impl<'n, 'a> Engine<'n, 'a> {
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v } ));
@@ -74,7 +74,7 @@ impl<'n, 'a> Engine<'n, 'a> {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
let mut ostream = match writer_from_opts(opt.value_of("out")) {
@@ -97,10 +97,10 @@ impl<'n, 'a> Engine<'n, 'a> {
}
}
fn _jobs_get(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
fn _jobs_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut call = self.hub.jobs().get(opt.value_of("team-id").unwrap_or(""), opt.value_of("job-id").unwrap_or(""));
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
_ => {
@@ -113,7 +113,7 @@ impl<'n, 'a> Engine<'n, 'a> {
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v } ));
@@ -126,7 +126,7 @@ impl<'n, 'a> Engine<'n, 'a> {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
let mut ostream = match writer_from_opts(opt.value_of("out")) {
@@ -149,13 +149,13 @@ impl<'n, 'a> Engine<'n, 'a> {
}
}
fn _jobs_insert(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
fn _jobs_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut field_cursor = FieldCursor::default();
let mut object = json::value::Value::Object(Default::default());
for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() {
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let last_errc = err.issues.len();
let (key, value) = parse_kv_arg(&*kvarg, err, false);
let mut temp_cursor = field_cursor.clone();
@@ -169,8 +169,8 @@ impl<'n, 'a> Engine<'n, 'a> {
}
continue;
}
let type_info: Option<(&'static str, JsonTypeInfo)> =
let type_info: Option<(&'static str, JsonTypeInfo)> =
match &temp_cursor.to_string()[..] {
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
@@ -200,7 +200,7 @@ impl<'n, 'a> Engine<'n, 'a> {
let lat: f64 = arg_from_str(&opt.value_of("lat").unwrap_or(""), err, "<lat>", "number");
let lng: f64 = arg_from_str(&opt.value_of("lng").unwrap_or(""), err, "<lng>", "number");
let mut call = self.hub.jobs().insert(request, opt.value_of("team-id").unwrap_or(""), opt.value_of("address").unwrap_or(""), lat, lng, opt.value_of("title").unwrap_or(""));
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
"note" => {
@@ -228,7 +228,7 @@ impl<'n, 'a> Engine<'n, 'a> {
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v.extend(["note", "custom-field", "customer-phone-number", "customer-name", "assignee"].iter().map(|v|*v));
@@ -242,7 +242,7 @@ impl<'n, 'a> Engine<'n, 'a> {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
let mut ostream = match writer_from_opts(opt.value_of("out")) {
@@ -265,10 +265,10 @@ impl<'n, 'a> Engine<'n, 'a> {
}
}
fn _jobs_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
fn _jobs_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut call = self.hub.jobs().list(opt.value_of("team-id").unwrap_or(""));
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
"page-token" => {
@@ -293,7 +293,7 @@ impl<'n, 'a> Engine<'n, 'a> {
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v.extend(["page-token", "min-modified-timestamp-ms", "max-results", "omit-job-changes"].iter().map(|v|*v));
@@ -307,7 +307,7 @@ impl<'n, 'a> Engine<'n, 'a> {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
let mut ostream = match writer_from_opts(opt.value_of("out")) {
@@ -330,13 +330,13 @@ impl<'n, 'a> Engine<'n, 'a> {
}
}
fn _jobs_patch(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
fn _jobs_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut field_cursor = FieldCursor::default();
let mut object = json::value::Value::Object(Default::default());
for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() {
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let last_errc = err.issues.len();
let (key, value) = parse_kv_arg(&*kvarg, err, false);
let mut temp_cursor = field_cursor.clone();
@@ -350,8 +350,8 @@ impl<'n, 'a> Engine<'n, 'a> {
}
continue;
}
let type_info: Option<(&'static str, JsonTypeInfo)> =
let type_info: Option<(&'static str, JsonTypeInfo)> =
match &temp_cursor.to_string()[..] {
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
@@ -379,7 +379,7 @@ impl<'n, 'a> Engine<'n, 'a> {
}
let mut request: api::Job = json::value::from_value(object).unwrap();
let mut call = self.hub.jobs().patch(request, opt.value_of("team-id").unwrap_or(""), opt.value_of("job-id").unwrap_or(""));
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
"title" => {
@@ -422,7 +422,7 @@ impl<'n, 'a> Engine<'n, 'a> {
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v.extend(["customer-name", "title", "note", "assignee", "customer-phone-number", "address", "lat", "progress", "lng", "custom-field"].iter().map(|v|*v));
@@ -436,7 +436,7 @@ impl<'n, 'a> Engine<'n, 'a> {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
let mut ostream = match writer_from_opts(opt.value_of("out")) {
@@ -459,13 +459,13 @@ impl<'n, 'a> Engine<'n, 'a> {
}
}
fn _jobs_update(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
fn _jobs_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut field_cursor = FieldCursor::default();
let mut object = json::value::Value::Object(Default::default());
for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() {
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let last_errc = err.issues.len();
let (key, value) = parse_kv_arg(&*kvarg, err, false);
let mut temp_cursor = field_cursor.clone();
@@ -479,8 +479,8 @@ impl<'n, 'a> Engine<'n, 'a> {
}
continue;
}
let type_info: Option<(&'static str, JsonTypeInfo)> =
let type_info: Option<(&'static str, JsonTypeInfo)> =
match &temp_cursor.to_string()[..] {
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
@@ -508,7 +508,7 @@ impl<'n, 'a> Engine<'n, 'a> {
}
let mut request: api::Job = json::value::from_value(object).unwrap();
let mut call = self.hub.jobs().update(request, opt.value_of("team-id").unwrap_or(""), opt.value_of("job-id").unwrap_or(""));
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
"title" => {
@@ -551,7 +551,7 @@ impl<'n, 'a> Engine<'n, 'a> {
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v.extend(["customer-name", "title", "note", "assignee", "customer-phone-number", "address", "lat", "progress", "lng", "custom-field"].iter().map(|v|*v));
@@ -565,7 +565,7 @@ impl<'n, 'a> Engine<'n, 'a> {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
let mut ostream = match writer_from_opts(opt.value_of("out")) {
@@ -588,10 +588,10 @@ impl<'n, 'a> Engine<'n, 'a> {
}
}
fn _location_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
fn _location_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut call = self.hub.location().list(opt.value_of("team-id").unwrap_or(""), opt.value_of("worker-email").unwrap_or(""), opt.value_of("start-timestamp-ms").unwrap_or(""));
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
"page-token" => {
@@ -610,7 +610,7 @@ impl<'n, 'a> Engine<'n, 'a> {
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v.extend(["page-token", "max-results"].iter().map(|v|*v));
@@ -624,7 +624,7 @@ impl<'n, 'a> Engine<'n, 'a> {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
let mut ostream = match writer_from_opts(opt.value_of("out")) {
@@ -647,10 +647,10 @@ impl<'n, 'a> Engine<'n, 'a> {
}
}
fn _schedule_get(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
fn _schedule_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut call = self.hub.schedule().get(opt.value_of("team-id").unwrap_or(""), opt.value_of("job-id").unwrap_or(""));
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
_ => {
@@ -663,7 +663,7 @@ impl<'n, 'a> Engine<'n, 'a> {
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v } ));
@@ -676,7 +676,7 @@ impl<'n, 'a> Engine<'n, 'a> {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
let mut ostream = match writer_from_opts(opt.value_of("out")) {
@@ -699,13 +699,13 @@ impl<'n, 'a> Engine<'n, 'a> {
}
}
fn _schedule_patch(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
fn _schedule_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut field_cursor = FieldCursor::default();
let mut object = json::value::Value::Object(Default::default());
for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() {
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let last_errc = err.issues.len();
let (key, value) = parse_kv_arg(&*kvarg, err, false);
let mut temp_cursor = field_cursor.clone();
@@ -719,8 +719,8 @@ impl<'n, 'a> Engine<'n, 'a> {
}
continue;
}
let type_info: Option<(&'static str, JsonTypeInfo)> =
let type_info: Option<(&'static str, JsonTypeInfo)> =
match &temp_cursor.to_string()[..] {
"duration" => Some(("duration", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
@@ -739,7 +739,7 @@ impl<'n, 'a> Engine<'n, 'a> {
}
let mut request: api::Schedule = json::value::from_value(object).unwrap();
let mut call = self.hub.schedule().patch(request, opt.value_of("team-id").unwrap_or(""), opt.value_of("job-id").unwrap_or(""));
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
"start-time" => {
@@ -764,7 +764,7 @@ impl<'n, 'a> Engine<'n, 'a> {
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v.extend(["duration", "all-day", "end-time", "start-time"].iter().map(|v|*v));
@@ -778,7 +778,7 @@ impl<'n, 'a> Engine<'n, 'a> {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
let mut ostream = match writer_from_opts(opt.value_of("out")) {
@@ -801,13 +801,13 @@ impl<'n, 'a> Engine<'n, 'a> {
}
}
fn _schedule_update(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
fn _schedule_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut field_cursor = FieldCursor::default();
let mut object = json::value::Value::Object(Default::default());
for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() {
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let last_errc = err.issues.len();
let (key, value) = parse_kv_arg(&*kvarg, err, false);
let mut temp_cursor = field_cursor.clone();
@@ -821,8 +821,8 @@ impl<'n, 'a> Engine<'n, 'a> {
}
continue;
}
let type_info: Option<(&'static str, JsonTypeInfo)> =
let type_info: Option<(&'static str, JsonTypeInfo)> =
match &temp_cursor.to_string()[..] {
"duration" => Some(("duration", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
@@ -841,7 +841,7 @@ impl<'n, 'a> Engine<'n, 'a> {
}
let mut request: api::Schedule = json::value::from_value(object).unwrap();
let mut call = self.hub.schedule().update(request, opt.value_of("team-id").unwrap_or(""), opt.value_of("job-id").unwrap_or(""));
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
"start-time" => {
@@ -866,7 +866,7 @@ impl<'n, 'a> Engine<'n, 'a> {
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v.extend(["duration", "all-day", "end-time", "start-time"].iter().map(|v|*v));
@@ -880,7 +880,7 @@ impl<'n, 'a> Engine<'n, 'a> {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
let mut ostream = match writer_from_opts(opt.value_of("out")) {
@@ -903,10 +903,10 @@ impl<'n, 'a> Engine<'n, 'a> {
}
}
fn _team_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
fn _team_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut call = self.hub.team().list();
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
"worker" => {
@@ -928,7 +928,7 @@ impl<'n, 'a> Engine<'n, 'a> {
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v.extend(["admin", "worker", "dispatcher"].iter().map(|v|*v));
@@ -942,7 +942,7 @@ impl<'n, 'a> Engine<'n, 'a> {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
let mut ostream = match writer_from_opts(opt.value_of("out")) {
@@ -965,10 +965,10 @@ impl<'n, 'a> Engine<'n, 'a> {
}
}
fn _worker_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
fn _worker_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut call = self.hub.worker().list(opt.value_of("team-id").unwrap_or(""));
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
_ => {
@@ -981,7 +981,7 @@ impl<'n, 'a> Engine<'n, 'a> {
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v } ));
@@ -994,7 +994,7 @@ impl<'n, 'a> Engine<'n, 'a> {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
let mut ostream = match writer_from_opts(opt.value_of("out")) {
@@ -1123,14 +1123,14 @@ impl<'n, 'a> Engine<'n, 'a> {
}
// Please note that this call will fail if any part of the opt can't be handled
fn new(opt: ArgMatches<'a, 'n>) -> Result<Engine<'a, 'n>, InvalidOptionsError> {
fn new(opt: ArgMatches<'n>) -> Result<Engine<'n>, InvalidOptionsError> {
let (config_dir, secret) = {
let config_dir = match cmn::assure_config_dir_exists(opt.value_of("folder").unwrap_or("~/.google-service-cli")) {
Err(e) => return Err(InvalidOptionsError::single(e, 3)),
Ok(p) => p,
};
match cmn::application_secret_from_directory(&config_dir, "coordinate1-secret.json",
match cmn::application_secret_from_directory(&config_dir, "coordinate1-secret.json",
"{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") {
Ok(secret) => (config_dir, secret),
Err(e) => return Err(InvalidOptionsError::single(e, 4))
@@ -1150,7 +1150,7 @@ impl<'n, 'a> Engine<'n, 'a> {
db_dir: config_dir.clone(),
}, None);
let client =
let client =
if opt.is_present("debug") {
hyper::Client::with_connector(mock::TeeConnector {
connector: hyper::net::HttpsConnector::<hyper::net::Openssl>::default()
@@ -1189,7 +1189,7 @@ fn main() {
let mut exit_status = 0i32;
let arg_data = [
("custom-field-def", "methods: 'list'", vec![
("list",
("list",
Some(r##"Retrieves a list of custom field definitions for a team."##),
"Details at http://byron.github.io/google-apis-rs/google_coordinate1_cli/custom-field-def_list",
vec![
@@ -1214,7 +1214,7 @@ fn main() {
]),
("jobs", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![
("get",
("get",
Some(r##"Retrieves a job, including all the changes made to the job."##),
"Details at http://byron.github.io/google-apis-rs/google_coordinate1_cli/jobs_get",
vec![
@@ -1242,7 +1242,7 @@ fn main() {
Some(false),
Some(false)),
]),
("insert",
("insert",
Some(r##"Inserts a new job. Only the state field of the job should be set."##),
"Details at http://byron.github.io/google-apis-rs/google_coordinate1_cli/jobs_insert",
vec![
@@ -1294,7 +1294,7 @@ fn main() {
Some(false),
Some(false)),
]),
("list",
("list",
Some(r##"Retrieves jobs created or modified since the given timestamp."##),
"Details at http://byron.github.io/google-apis-rs/google_coordinate1_cli/jobs_list",
vec![
@@ -1316,7 +1316,7 @@ fn main() {
Some(false),
Some(false)),
]),
("patch",
("patch",
Some(r##"Updates a job. Fields that are set in the job state will be updated. This method supports patch semantics."##),
"Details at http://byron.github.io/google-apis-rs/google_coordinate1_cli/jobs_patch",
vec![
@@ -1350,7 +1350,7 @@ fn main() {
Some(false),
Some(false)),
]),
("update",
("update",
Some(r##"Updates a job. Fields that are set in the job state will be updated."##),
"Details at http://byron.github.io/google-apis-rs/google_coordinate1_cli/jobs_update",
vec![
@@ -1387,7 +1387,7 @@ fn main() {
]),
("location", "methods: 'list'", vec![
("list",
("list",
Some(r##"Retrieves a list of locations for a worker."##),
"Details at http://byron.github.io/google-apis-rs/google_coordinate1_cli/location_list",
vec![
@@ -1424,7 +1424,7 @@ fn main() {
]),
("schedule", "methods: 'get', 'patch' and 'update'", vec![
("get",
("get",
Some(r##"Retrieves the schedule for a job."##),
"Details at http://byron.github.io/google-apis-rs/google_coordinate1_cli/schedule_get",
vec![
@@ -1452,7 +1452,7 @@ fn main() {
Some(false),
Some(false)),
]),
("patch",
("patch",
Some(r##"Replaces the schedule of a job with the provided schedule. This method supports patch semantics."##),
"Details at http://byron.github.io/google-apis-rs/google_coordinate1_cli/schedule_patch",
vec![
@@ -1486,7 +1486,7 @@ fn main() {
Some(false),
Some(false)),
]),
("update",
("update",
Some(r##"Replaces the schedule of a job with the provided schedule."##),
"Details at http://byron.github.io/google-apis-rs/google_coordinate1_cli/schedule_update",
vec![
@@ -1523,7 +1523,7 @@ fn main() {
]),
("team", "methods: 'list'", vec![
("list",
("list",
Some(r##"Retrieves a list of teams for a user."##),
"Details at http://byron.github.io/google-apis-rs/google_coordinate1_cli/team_list",
vec![
@@ -1542,7 +1542,7 @@ fn main() {
]),
("worker", "methods: 'list'", vec![
("list",
("list",
Some(r##"Retrieves a list of workers in a team."##),
"Details at http://byron.github.io/google-apis-rs/google_coordinate1_cli/worker_list",
vec![
@@ -1570,7 +1570,7 @@ fn main() {
let mut app = App::new("coordinate1")
.author("Sebastian Thiel <byronimo@gmail.com>")
.version("0.3.2+20150811")
.version("0.3.3+20150811")
.about("Lets you view and manage jobs in a Coordinate team.")
.after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_coordinate1_cli")
.arg(Arg::with_name("url")
@@ -1594,7 +1594,7 @@ fn main() {
.multiple(false)
.takes_value(false));
for &(main_command_name, ref about, ref subcommands) in arg_data.iter() {
for &(main_command_name, about, ref subcommands) in arg_data.iter() {
let mut mcmd = SubCommand::with_name(main_command_name).about(about);
for &(sub_command_name, ref desc, url_info, ref args) in subcommands {
@@ -1605,7 +1605,7 @@ fn main() {
scmd = scmd.after_help(url_info);
for &(ref arg_name, ref flag, ref desc, ref required, ref multi) in args {
let arg_name_str =
let arg_name_str =
match (arg_name, flag) {
(&Some(an), _ ) => an,
(_ , &Some(f)) => f,