mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-02-23 15:49:49 +01:00
fix(version-up): code updated to v0.1.6, latest CLI
* also includes publishing tag files
This commit is contained in:
@@ -19,37 +19,38 @@ use std::io::{self, Write};
|
||||
|
||||
docopt!(Options derive Debug, "
|
||||
Usage:
|
||||
coordinate1 [options] custom-field-def list <team-id> [-p <v>]... [-o <out>]
|
||||
coordinate1 [options] jobs get <team-id> <job-id> [-p <v>]... [-o <out>]
|
||||
coordinate1 [options] jobs insert <team-id> <address> <lat> <lng> <title> -r <kv>... [-p <v>]... [-o <out>]
|
||||
coordinate1 [options] jobs list <team-id> [-p <v>]... [-o <out>]
|
||||
coordinate1 [options] jobs patch <team-id> <job-id> -r <kv>... [-p <v>]... [-o <out>]
|
||||
coordinate1 [options] jobs update <team-id> <job-id> -r <kv>... [-p <v>]... [-o <out>]
|
||||
coordinate1 [options] location list <team-id> <worker-email> <start-timestamp-ms> [-p <v>]... [-o <out>]
|
||||
coordinate1 [options] schedule get <team-id> <job-id> [-p <v>]... [-o <out>]
|
||||
coordinate1 [options] schedule patch <team-id> <job-id> -r <kv>... [-p <v>]... [-o <out>]
|
||||
coordinate1 [options] schedule update <team-id> <job-id> -r <kv>... [-p <v>]... [-o <out>]
|
||||
coordinate1 [options] team list [-p <v>]... [-o <out>]
|
||||
coordinate1 [options] worker list <team-id> [-p <v>]... [-o <out>]
|
||||
coordinate1 [options] custom-field-def list <team-id> [-p <v>...] [-o <out>]
|
||||
coordinate1 [options] jobs get <team-id> <job-id> [-p <v>...] [-o <out>]
|
||||
coordinate1 [options] jobs insert <team-id> <address> <lat> <lng> <title> -r <kv>... [-p <v>...] [-o <out>]
|
||||
coordinate1 [options] jobs list <team-id> [-p <v>...] [-o <out>]
|
||||
coordinate1 [options] jobs patch <team-id> <job-id> -r <kv>... [-p <v>...] [-o <out>]
|
||||
coordinate1 [options] jobs update <team-id> <job-id> -r <kv>... [-p <v>...] [-o <out>]
|
||||
coordinate1 [options] location list <team-id> <worker-email> <start-timestamp-ms> [-p <v>...] [-o <out>]
|
||||
coordinate1 [options] schedule get <team-id> <job-id> [-p <v>...] [-o <out>]
|
||||
coordinate1 [options] schedule patch <team-id> <job-id> -r <kv>... [-p <v>...] [-o <out>]
|
||||
coordinate1 [options] schedule update <team-id> <job-id> -r <kv>... [-p <v>...] [-o <out>]
|
||||
coordinate1 [options] team list [-p <v>...] [-o <out>]
|
||||
coordinate1 [options] worker list <team-id> [-p <v>...] [-o <out>]
|
||||
coordinate1 --help
|
||||
|
||||
All documentation details can be found TODO: <URL to github.io docs here, see #51>
|
||||
All documentation details can be found at
|
||||
http://byron.github.io/google-apis-rs/google_coordinate1_cli/index.html
|
||||
|
||||
Configuration:
|
||||
--scope <url>
|
||||
Specify the authentication a method should be executed in. Each scope requires
|
||||
the user to grant this application permission to use it.
|
||||
Specify the authentication a method should be executed in. Each scope
|
||||
requires the user to grant this application permission to use it.
|
||||
If unset, it defaults to the shortest scope url for a particular method.
|
||||
--config-dir <folder>
|
||||
A directory into which we will store our persistent data. Defaults to a user-writable
|
||||
directory that we will create during the first invocation.
|
||||
A directory into which we will store our persistent data. Defaults to
|
||||
a user-writable directory that we will create during the first invocation.
|
||||
[default: ~/.google-service-cli]
|
||||
--debug
|
||||
Output all server communication to standard error. `tx` and `rx` are placed into
|
||||
the same stream.
|
||||
Output all server communication to standard error. `tx` and `rx` are placed
|
||||
into the same stream.
|
||||
--debug-auth
|
||||
Output all communication related to authentication to standard error. `tx` and `rx` are placed into
|
||||
the same stream.
|
||||
Output all communication related to authentication to standard error. `tx`
|
||||
and `rx` are placed into the same stream.
|
||||
");
|
||||
|
||||
mod cmn;
|
||||
@@ -98,6 +99,9 @@ impl Engine {
|
||||
None
|
||||
} else {
|
||||
assert!(err.issues.len() == 0);
|
||||
if self.opt.flag_scope.len() > 0 {
|
||||
call = call.add_scope(&self.opt.flag_scope);
|
||||
}
|
||||
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
||||
match match protocol {
|
||||
"standard-request" => call.doit(),
|
||||
@@ -141,6 +145,9 @@ impl Engine {
|
||||
None
|
||||
} else {
|
||||
assert!(err.issues.len() == 0);
|
||||
if self.opt.flag_scope.len() > 0 {
|
||||
call = call.add_scope(&self.opt.flag_scope);
|
||||
}
|
||||
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
||||
match match protocol {
|
||||
"standard-request" => call.doit(),
|
||||
@@ -157,53 +164,23 @@ impl Engine {
|
||||
|
||||
fn _jobs_insert(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Option<api::Error> {
|
||||
let mut request = api::Job::default();
|
||||
let lat: f64 = arg_from_str(&self.opt.arg_lat, err, "<lat>", "number");
|
||||
let lng: f64 = arg_from_str(&self.opt.arg_lng, err, "<lng>", "number");
|
||||
let mut call = self.hub.jobs().insert(&request, &self.opt.arg_team_id, &self.opt.arg_address, lat, lng, &self.opt.arg_title);
|
||||
for parg in self.opt.arg_v.iter() {
|
||||
let (key, value) = parse_kv_arg(&*parg, err, false);
|
||||
match key {
|
||||
"note" => {
|
||||
call = call.note(value.unwrap_or(""));
|
||||
},
|
||||
"customer-phone-number" => {
|
||||
call = call.customer_phone_number(value.unwrap_or(""));
|
||||
},
|
||||
"customer-name" => {
|
||||
call = call.customer_name(value.unwrap_or(""));
|
||||
},
|
||||
"custom-field" => {
|
||||
call = call.add_custom_field(value.unwrap_or(""));
|
||||
},
|
||||
"assignee" => {
|
||||
call = call.assignee(value.unwrap_or(""));
|
||||
},
|
||||
"alt"
|
||||
|"fields"
|
||||
|"key"
|
||||
|"oauth-token"
|
||||
|"pretty-print"
|
||||
|"quota-user"
|
||||
|"user-ip" => {
|
||||
let map = [
|
||||
("oauth-token", "oauth_token"),
|
||||
("pretty-print", "prettyPrint"),
|
||||
("quota-user", "quotaUser"),
|
||||
("user-ip", "userIp"),
|
||||
];
|
||||
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
||||
},
|
||||
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
||||
}
|
||||
}
|
||||
|
||||
let mut field_name = FieldCursor::default();
|
||||
let mut request = api::Job::default();
|
||||
let mut field_cursor = FieldCursor::default();
|
||||
for kvarg in self.opt.arg_kv.iter() {
|
||||
let last_errc = err.issues.len();
|
||||
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
||||
if let Err(field_err) = field_name.set(&*key) {
|
||||
let mut temp_cursor = field_cursor.clone();
|
||||
if let Err(field_err) = temp_cursor.set(&*key) {
|
||||
err.issues.push(field_err);
|
||||
}
|
||||
if value.is_none() {
|
||||
field_cursor = temp_cursor.clone();
|
||||
if err.issues.len() > last_errc {
|
||||
err.issues.remove(last_errc);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
fn request_state_custom_fields_init(request: &mut api::Job) {
|
||||
request_state_init(request);
|
||||
if request.state.as_mut().unwrap().custom_fields.is_none() {
|
||||
@@ -224,7 +201,7 @@ impl Engine {
|
||||
}
|
||||
}
|
||||
|
||||
match &field_name.to_string()[..] {
|
||||
match &temp_cursor.to_string()[..] {
|
||||
"kind" => {
|
||||
request.kind = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
@@ -286,15 +263,57 @@ impl Engine {
|
||||
request.state.as_mut().unwrap().custom_fields.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
_ => {
|
||||
err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string())));
|
||||
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string())));
|
||||
}
|
||||
}
|
||||
}
|
||||
let lat: f64 = arg_from_str(&self.opt.arg_lat, err, "<lat>", "number");
|
||||
let lng: f64 = arg_from_str(&self.opt.arg_lng, err, "<lng>", "number");
|
||||
let mut call = self.hub.jobs().insert(request, &self.opt.arg_team_id, &self.opt.arg_address, lat, lng, &self.opt.arg_title);
|
||||
for parg in self.opt.arg_v.iter() {
|
||||
let (key, value) = parse_kv_arg(&*parg, err, false);
|
||||
match key {
|
||||
"note" => {
|
||||
call = call.note(value.unwrap_or(""));
|
||||
},
|
||||
"customer-phone-number" => {
|
||||
call = call.customer_phone_number(value.unwrap_or(""));
|
||||
},
|
||||
"customer-name" => {
|
||||
call = call.customer_name(value.unwrap_or(""));
|
||||
},
|
||||
"custom-field" => {
|
||||
call = call.add_custom_field(value.unwrap_or(""));
|
||||
},
|
||||
"assignee" => {
|
||||
call = call.assignee(value.unwrap_or(""));
|
||||
},
|
||||
"alt"
|
||||
|"fields"
|
||||
|"key"
|
||||
|"oauth-token"
|
||||
|"pretty-print"
|
||||
|"quota-user"
|
||||
|"user-ip" => {
|
||||
let map = [
|
||||
("oauth-token", "oauth_token"),
|
||||
("pretty-print", "prettyPrint"),
|
||||
("quota-user", "quotaUser"),
|
||||
("user-ip", "userIp"),
|
||||
];
|
||||
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
||||
},
|
||||
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
||||
}
|
||||
}
|
||||
let protocol = "standard-request";
|
||||
if dry_run {
|
||||
None
|
||||
} else {
|
||||
assert!(err.issues.len() == 0);
|
||||
if self.opt.flag_scope.len() > 0 {
|
||||
call = call.add_scope(&self.opt.flag_scope);
|
||||
}
|
||||
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
||||
match match protocol {
|
||||
"standard-request" => call.doit(),
|
||||
@@ -347,6 +366,9 @@ impl Engine {
|
||||
None
|
||||
} else {
|
||||
assert!(err.issues.len() == 0);
|
||||
if self.opt.flag_scope.len() > 0 {
|
||||
call = call.add_scope(&self.opt.flag_scope);
|
||||
}
|
||||
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
||||
match match protocol {
|
||||
"standard-request" => call.doit(),
|
||||
@@ -363,66 +385,23 @@ impl Engine {
|
||||
|
||||
fn _jobs_patch(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Option<api::Error> {
|
||||
let mut request = api::Job::default();
|
||||
let mut call = self.hub.jobs().patch(&request, &self.opt.arg_team_id, &self.opt.arg_job_id);
|
||||
for parg in self.opt.arg_v.iter() {
|
||||
let (key, value) = parse_kv_arg(&*parg, err, false);
|
||||
match key {
|
||||
"title" => {
|
||||
call = call.title(value.unwrap_or(""));
|
||||
},
|
||||
"progress" => {
|
||||
call = call.progress(value.unwrap_or(""));
|
||||
},
|
||||
"note" => {
|
||||
call = call.note(value.unwrap_or(""));
|
||||
},
|
||||
"lng" => {
|
||||
call = call.lng(arg_from_str(value.unwrap_or("0.0"), err, "lng", "number"));
|
||||
},
|
||||
"lat" => {
|
||||
call = call.lat(arg_from_str(value.unwrap_or("0.0"), err, "lat", "number"));
|
||||
},
|
||||
"customer-phone-number" => {
|
||||
call = call.customer_phone_number(value.unwrap_or(""));
|
||||
},
|
||||
"customer-name" => {
|
||||
call = call.customer_name(value.unwrap_or(""));
|
||||
},
|
||||
"custom-field" => {
|
||||
call = call.add_custom_field(value.unwrap_or(""));
|
||||
},
|
||||
"assignee" => {
|
||||
call = call.assignee(value.unwrap_or(""));
|
||||
},
|
||||
"address" => {
|
||||
call = call.address(value.unwrap_or(""));
|
||||
},
|
||||
"alt"
|
||||
|"fields"
|
||||
|"key"
|
||||
|"oauth-token"
|
||||
|"pretty-print"
|
||||
|"quota-user"
|
||||
|"user-ip" => {
|
||||
let map = [
|
||||
("oauth-token", "oauth_token"),
|
||||
("pretty-print", "prettyPrint"),
|
||||
("quota-user", "quotaUser"),
|
||||
("user-ip", "userIp"),
|
||||
];
|
||||
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
||||
},
|
||||
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
||||
}
|
||||
}
|
||||
|
||||
let mut field_name = FieldCursor::default();
|
||||
let mut request = api::Job::default();
|
||||
let mut field_cursor = FieldCursor::default();
|
||||
for kvarg in self.opt.arg_kv.iter() {
|
||||
let last_errc = err.issues.len();
|
||||
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
||||
if let Err(field_err) = field_name.set(&*key) {
|
||||
let mut temp_cursor = field_cursor.clone();
|
||||
if let Err(field_err) = temp_cursor.set(&*key) {
|
||||
err.issues.push(field_err);
|
||||
}
|
||||
if value.is_none() {
|
||||
field_cursor = temp_cursor.clone();
|
||||
if err.issues.len() > last_errc {
|
||||
err.issues.remove(last_errc);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
fn request_state_custom_fields_init(request: &mut api::Job) {
|
||||
request_state_init(request);
|
||||
if request.state.as_mut().unwrap().custom_fields.is_none() {
|
||||
@@ -443,7 +422,7 @@ impl Engine {
|
||||
}
|
||||
}
|
||||
|
||||
match &field_name.to_string()[..] {
|
||||
match &temp_cursor.to_string()[..] {
|
||||
"kind" => {
|
||||
request.kind = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
@@ -505,15 +484,70 @@ impl Engine {
|
||||
request.state.as_mut().unwrap().custom_fields.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
_ => {
|
||||
err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string())));
|
||||
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string())));
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut call = self.hub.jobs().patch(request, &self.opt.arg_team_id, &self.opt.arg_job_id);
|
||||
for parg in self.opt.arg_v.iter() {
|
||||
let (key, value) = parse_kv_arg(&*parg, err, false);
|
||||
match key {
|
||||
"title" => {
|
||||
call = call.title(value.unwrap_or(""));
|
||||
},
|
||||
"progress" => {
|
||||
call = call.progress(value.unwrap_or(""));
|
||||
},
|
||||
"note" => {
|
||||
call = call.note(value.unwrap_or(""));
|
||||
},
|
||||
"lng" => {
|
||||
call = call.lng(arg_from_str(value.unwrap_or("0.0"), err, "lng", "number"));
|
||||
},
|
||||
"lat" => {
|
||||
call = call.lat(arg_from_str(value.unwrap_or("0.0"), err, "lat", "number"));
|
||||
},
|
||||
"customer-phone-number" => {
|
||||
call = call.customer_phone_number(value.unwrap_or(""));
|
||||
},
|
||||
"customer-name" => {
|
||||
call = call.customer_name(value.unwrap_or(""));
|
||||
},
|
||||
"custom-field" => {
|
||||
call = call.add_custom_field(value.unwrap_or(""));
|
||||
},
|
||||
"assignee" => {
|
||||
call = call.assignee(value.unwrap_or(""));
|
||||
},
|
||||
"address" => {
|
||||
call = call.address(value.unwrap_or(""));
|
||||
},
|
||||
"alt"
|
||||
|"fields"
|
||||
|"key"
|
||||
|"oauth-token"
|
||||
|"pretty-print"
|
||||
|"quota-user"
|
||||
|"user-ip" => {
|
||||
let map = [
|
||||
("oauth-token", "oauth_token"),
|
||||
("pretty-print", "prettyPrint"),
|
||||
("quota-user", "quotaUser"),
|
||||
("user-ip", "userIp"),
|
||||
];
|
||||
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
||||
},
|
||||
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
||||
}
|
||||
}
|
||||
let protocol = "standard-request";
|
||||
if dry_run {
|
||||
None
|
||||
} else {
|
||||
assert!(err.issues.len() == 0);
|
||||
if self.opt.flag_scope.len() > 0 {
|
||||
call = call.add_scope(&self.opt.flag_scope);
|
||||
}
|
||||
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
||||
match match protocol {
|
||||
"standard-request" => call.doit(),
|
||||
@@ -530,66 +564,23 @@ impl Engine {
|
||||
|
||||
fn _jobs_update(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Option<api::Error> {
|
||||
let mut request = api::Job::default();
|
||||
let mut call = self.hub.jobs().update(&request, &self.opt.arg_team_id, &self.opt.arg_job_id);
|
||||
for parg in self.opt.arg_v.iter() {
|
||||
let (key, value) = parse_kv_arg(&*parg, err, false);
|
||||
match key {
|
||||
"title" => {
|
||||
call = call.title(value.unwrap_or(""));
|
||||
},
|
||||
"progress" => {
|
||||
call = call.progress(value.unwrap_or(""));
|
||||
},
|
||||
"note" => {
|
||||
call = call.note(value.unwrap_or(""));
|
||||
},
|
||||
"lng" => {
|
||||
call = call.lng(arg_from_str(value.unwrap_or("0.0"), err, "lng", "number"));
|
||||
},
|
||||
"lat" => {
|
||||
call = call.lat(arg_from_str(value.unwrap_or("0.0"), err, "lat", "number"));
|
||||
},
|
||||
"customer-phone-number" => {
|
||||
call = call.customer_phone_number(value.unwrap_or(""));
|
||||
},
|
||||
"customer-name" => {
|
||||
call = call.customer_name(value.unwrap_or(""));
|
||||
},
|
||||
"custom-field" => {
|
||||
call = call.add_custom_field(value.unwrap_or(""));
|
||||
},
|
||||
"assignee" => {
|
||||
call = call.assignee(value.unwrap_or(""));
|
||||
},
|
||||
"address" => {
|
||||
call = call.address(value.unwrap_or(""));
|
||||
},
|
||||
"alt"
|
||||
|"fields"
|
||||
|"key"
|
||||
|"oauth-token"
|
||||
|"pretty-print"
|
||||
|"quota-user"
|
||||
|"user-ip" => {
|
||||
let map = [
|
||||
("oauth-token", "oauth_token"),
|
||||
("pretty-print", "prettyPrint"),
|
||||
("quota-user", "quotaUser"),
|
||||
("user-ip", "userIp"),
|
||||
];
|
||||
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
||||
},
|
||||
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
||||
}
|
||||
}
|
||||
|
||||
let mut field_name = FieldCursor::default();
|
||||
let mut request = api::Job::default();
|
||||
let mut field_cursor = FieldCursor::default();
|
||||
for kvarg in self.opt.arg_kv.iter() {
|
||||
let last_errc = err.issues.len();
|
||||
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
||||
if let Err(field_err) = field_name.set(&*key) {
|
||||
let mut temp_cursor = field_cursor.clone();
|
||||
if let Err(field_err) = temp_cursor.set(&*key) {
|
||||
err.issues.push(field_err);
|
||||
}
|
||||
if value.is_none() {
|
||||
field_cursor = temp_cursor.clone();
|
||||
if err.issues.len() > last_errc {
|
||||
err.issues.remove(last_errc);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
fn request_state_custom_fields_init(request: &mut api::Job) {
|
||||
request_state_init(request);
|
||||
if request.state.as_mut().unwrap().custom_fields.is_none() {
|
||||
@@ -610,7 +601,7 @@ impl Engine {
|
||||
}
|
||||
}
|
||||
|
||||
match &field_name.to_string()[..] {
|
||||
match &temp_cursor.to_string()[..] {
|
||||
"kind" => {
|
||||
request.kind = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
@@ -672,15 +663,70 @@ impl Engine {
|
||||
request.state.as_mut().unwrap().custom_fields.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
_ => {
|
||||
err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string())));
|
||||
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string())));
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut call = self.hub.jobs().update(request, &self.opt.arg_team_id, &self.opt.arg_job_id);
|
||||
for parg in self.opt.arg_v.iter() {
|
||||
let (key, value) = parse_kv_arg(&*parg, err, false);
|
||||
match key {
|
||||
"title" => {
|
||||
call = call.title(value.unwrap_or(""));
|
||||
},
|
||||
"progress" => {
|
||||
call = call.progress(value.unwrap_or(""));
|
||||
},
|
||||
"note" => {
|
||||
call = call.note(value.unwrap_or(""));
|
||||
},
|
||||
"lng" => {
|
||||
call = call.lng(arg_from_str(value.unwrap_or("0.0"), err, "lng", "number"));
|
||||
},
|
||||
"lat" => {
|
||||
call = call.lat(arg_from_str(value.unwrap_or("0.0"), err, "lat", "number"));
|
||||
},
|
||||
"customer-phone-number" => {
|
||||
call = call.customer_phone_number(value.unwrap_or(""));
|
||||
},
|
||||
"customer-name" => {
|
||||
call = call.customer_name(value.unwrap_or(""));
|
||||
},
|
||||
"custom-field" => {
|
||||
call = call.add_custom_field(value.unwrap_or(""));
|
||||
},
|
||||
"assignee" => {
|
||||
call = call.assignee(value.unwrap_or(""));
|
||||
},
|
||||
"address" => {
|
||||
call = call.address(value.unwrap_or(""));
|
||||
},
|
||||
"alt"
|
||||
|"fields"
|
||||
|"key"
|
||||
|"oauth-token"
|
||||
|"pretty-print"
|
||||
|"quota-user"
|
||||
|"user-ip" => {
|
||||
let map = [
|
||||
("oauth-token", "oauth_token"),
|
||||
("pretty-print", "prettyPrint"),
|
||||
("quota-user", "quotaUser"),
|
||||
("user-ip", "userIp"),
|
||||
];
|
||||
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
||||
},
|
||||
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
||||
}
|
||||
}
|
||||
let protocol = "standard-request";
|
||||
if dry_run {
|
||||
None
|
||||
} else {
|
||||
assert!(err.issues.len() == 0);
|
||||
if self.opt.flag_scope.len() > 0 {
|
||||
call = call.add_scope(&self.opt.flag_scope);
|
||||
}
|
||||
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
||||
match match protocol {
|
||||
"standard-request" => call.doit(),
|
||||
@@ -730,6 +776,9 @@ impl Engine {
|
||||
None
|
||||
} else {
|
||||
assert!(err.issues.len() == 0);
|
||||
if self.opt.flag_scope.len() > 0 {
|
||||
call = call.add_scope(&self.opt.flag_scope);
|
||||
}
|
||||
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
||||
match match protocol {
|
||||
"standard-request" => call.doit(),
|
||||
@@ -773,6 +822,9 @@ impl Engine {
|
||||
None
|
||||
} else {
|
||||
assert!(err.issues.len() == 0);
|
||||
if self.opt.flag_scope.len() > 0 {
|
||||
call = call.add_scope(&self.opt.flag_scope);
|
||||
}
|
||||
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
||||
match match protocol {
|
||||
"standard-request" => call.doit(),
|
||||
@@ -789,8 +841,45 @@ impl Engine {
|
||||
|
||||
fn _schedule_patch(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Option<api::Error> {
|
||||
|
||||
let mut request = api::Schedule::default();
|
||||
let mut call = self.hub.schedule().patch(&request, &self.opt.arg_team_id, &self.opt.arg_job_id);
|
||||
let mut field_cursor = FieldCursor::default();
|
||||
for kvarg in self.opt.arg_kv.iter() {
|
||||
let last_errc = err.issues.len();
|
||||
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
||||
let mut temp_cursor = field_cursor.clone();
|
||||
if let Err(field_err) = temp_cursor.set(&*key) {
|
||||
err.issues.push(field_err);
|
||||
}
|
||||
if value.is_none() {
|
||||
field_cursor = temp_cursor.clone();
|
||||
if err.issues.len() > last_errc {
|
||||
err.issues.remove(last_errc);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
match &temp_cursor.to_string()[..] {
|
||||
"duration" => {
|
||||
request.duration = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
"kind" => {
|
||||
request.kind = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
"all-day" => {
|
||||
request.all_day = Some(arg_from_str(value.unwrap_or("false"), err, "all-day", "boolean"));
|
||||
},
|
||||
"start-time" => {
|
||||
request.start_time = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
"end-time" => {
|
||||
request.end_time = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
_ => {
|
||||
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string())));
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut call = self.hub.schedule().patch(request, &self.opt.arg_team_id, &self.opt.arg_job_id);
|
||||
for parg in self.opt.arg_v.iter() {
|
||||
let (key, value) = parse_kv_arg(&*parg, err, false);
|
||||
match key {
|
||||
@@ -824,39 +913,14 @@ impl Engine {
|
||||
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
||||
}
|
||||
}
|
||||
|
||||
let mut field_name = FieldCursor::default();
|
||||
for kvarg in self.opt.arg_kv.iter() {
|
||||
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
||||
if let Err(field_err) = field_name.set(&*key) {
|
||||
err.issues.push(field_err);
|
||||
}
|
||||
match &field_name.to_string()[..] {
|
||||
"duration" => {
|
||||
request.duration = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
"kind" => {
|
||||
request.kind = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
"all-day" => {
|
||||
request.all_day = Some(arg_from_str(value.unwrap_or("false"), err, "all-day", "boolean"));
|
||||
},
|
||||
"start-time" => {
|
||||
request.start_time = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
"end-time" => {
|
||||
request.end_time = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
_ => {
|
||||
err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string())));
|
||||
}
|
||||
}
|
||||
}
|
||||
let protocol = "standard-request";
|
||||
if dry_run {
|
||||
None
|
||||
} else {
|
||||
assert!(err.issues.len() == 0);
|
||||
if self.opt.flag_scope.len() > 0 {
|
||||
call = call.add_scope(&self.opt.flag_scope);
|
||||
}
|
||||
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
||||
match match protocol {
|
||||
"standard-request" => call.doit(),
|
||||
@@ -873,8 +937,45 @@ impl Engine {
|
||||
|
||||
fn _schedule_update(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
||||
-> Option<api::Error> {
|
||||
|
||||
let mut request = api::Schedule::default();
|
||||
let mut call = self.hub.schedule().update(&request, &self.opt.arg_team_id, &self.opt.arg_job_id);
|
||||
let mut field_cursor = FieldCursor::default();
|
||||
for kvarg in self.opt.arg_kv.iter() {
|
||||
let last_errc = err.issues.len();
|
||||
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
||||
let mut temp_cursor = field_cursor.clone();
|
||||
if let Err(field_err) = temp_cursor.set(&*key) {
|
||||
err.issues.push(field_err);
|
||||
}
|
||||
if value.is_none() {
|
||||
field_cursor = temp_cursor.clone();
|
||||
if err.issues.len() > last_errc {
|
||||
err.issues.remove(last_errc);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
match &temp_cursor.to_string()[..] {
|
||||
"duration" => {
|
||||
request.duration = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
"kind" => {
|
||||
request.kind = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
"all-day" => {
|
||||
request.all_day = Some(arg_from_str(value.unwrap_or("false"), err, "all-day", "boolean"));
|
||||
},
|
||||
"start-time" => {
|
||||
request.start_time = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
"end-time" => {
|
||||
request.end_time = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
_ => {
|
||||
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string())));
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut call = self.hub.schedule().update(request, &self.opt.arg_team_id, &self.opt.arg_job_id);
|
||||
for parg in self.opt.arg_v.iter() {
|
||||
let (key, value) = parse_kv_arg(&*parg, err, false);
|
||||
match key {
|
||||
@@ -908,39 +1009,14 @@ impl Engine {
|
||||
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
||||
}
|
||||
}
|
||||
|
||||
let mut field_name = FieldCursor::default();
|
||||
for kvarg in self.opt.arg_kv.iter() {
|
||||
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
||||
if let Err(field_err) = field_name.set(&*key) {
|
||||
err.issues.push(field_err);
|
||||
}
|
||||
match &field_name.to_string()[..] {
|
||||
"duration" => {
|
||||
request.duration = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
"kind" => {
|
||||
request.kind = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
"all-day" => {
|
||||
request.all_day = Some(arg_from_str(value.unwrap_or("false"), err, "all-day", "boolean"));
|
||||
},
|
||||
"start-time" => {
|
||||
request.start_time = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
"end-time" => {
|
||||
request.end_time = Some(value.unwrap_or("").to_string());
|
||||
},
|
||||
_ => {
|
||||
err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string())));
|
||||
}
|
||||
}
|
||||
}
|
||||
let protocol = "standard-request";
|
||||
if dry_run {
|
||||
None
|
||||
} else {
|
||||
assert!(err.issues.len() == 0);
|
||||
if self.opt.flag_scope.len() > 0 {
|
||||
call = call.add_scope(&self.opt.flag_scope);
|
||||
}
|
||||
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
||||
match match protocol {
|
||||
"standard-request" => call.doit(),
|
||||
@@ -993,6 +1069,9 @@ impl Engine {
|
||||
None
|
||||
} else {
|
||||
assert!(err.issues.len() == 0);
|
||||
if self.opt.flag_scope.len() > 0 {
|
||||
call = call.add_scope(&self.opt.flag_scope);
|
||||
}
|
||||
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
||||
match match protocol {
|
||||
"standard-request" => call.doit(),
|
||||
@@ -1036,6 +1115,9 @@ impl Engine {
|
||||
None
|
||||
} else {
|
||||
assert!(err.issues.len() == 0);
|
||||
if self.opt.flag_scope.len() > 0 {
|
||||
call = call.add_scope(&self.opt.flag_scope);
|
||||
}
|
||||
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
||||
match match protocol {
|
||||
"standard-request" => call.doit(),
|
||||
@@ -1176,6 +1258,7 @@ impl Engine {
|
||||
|
||||
fn main() {
|
||||
let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit());
|
||||
let debug = opts.flag_debug;
|
||||
match Engine::new(opts) {
|
||||
Err(err) => {
|
||||
writeln!(io::stderr(), "{}", err).ok();
|
||||
@@ -1183,8 +1266,11 @@ fn main() {
|
||||
},
|
||||
Ok(engine) => {
|
||||
if let Some(err) = engine.doit() {
|
||||
writeln!(io::stderr(), "{:?}", err).ok();
|
||||
writeln!(io::stderr(), "{}", err).ok();
|
||||
if debug {
|
||||
writeln!(io::stderr(), "{:?}", err).ok();
|
||||
} else {
|
||||
writeln!(io::stderr(), "{}", err).ok();
|
||||
}
|
||||
env::set_exit_status(1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user