mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-02-23 15:49:49 +01:00
chore(code-up): latest version of all code
This commit is contained in:
@@ -4,12 +4,14 @@
|
||||
#![feature(plugin, exit_status)]
|
||||
#![allow(unused_variables, unused_imports, dead_code, unused_mut)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate clap;
|
||||
extern crate yup_oauth2 as oauth2;
|
||||
extern crate yup_hyper_mock as mock;
|
||||
extern crate serde;
|
||||
extern crate hyper;
|
||||
extern crate mime;
|
||||
extern crate strsim;
|
||||
extern crate google_groupsmigration1 as api;
|
||||
|
||||
use std::env;
|
||||
@@ -20,7 +22,7 @@ mod cmn;
|
||||
|
||||
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,
|
||||
protocol_from_str};
|
||||
calltype_from_str, remove_json_null_values};
|
||||
|
||||
use std::default::Default;
|
||||
use std::str::FromStr;
|
||||
@@ -37,6 +39,8 @@ enum DoitError {
|
||||
struct Engine<'n, 'a> {
|
||||
opt: ArgMatches<'n, 'a>,
|
||||
hub: api::GroupsMigration<hyper::Client, Authenticator<DefaultAuthenticatorDelegate, JsonTokenStorage, hyper::Client>>,
|
||||
gp: Vec<&'static str>,
|
||||
gpm: Vec<(&'static str, &'static str)>,
|
||||
}
|
||||
|
||||
|
||||
@@ -47,26 +51,25 @@ impl<'n, 'a> Engine<'n, 'a> {
|
||||
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
|
||||
let (key, value) = parse_kv_arg(&*parg, err, false);
|
||||
match key {
|
||||
"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 found = false;
|
||||
for param in &self.gp {
|
||||
if key == *param {
|
||||
found = true;
|
||||
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
||||
Vec::new() + &self.gp + &[]
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let vals = opt.values_of("mode").unwrap();
|
||||
let protocol = protocol_from_str(vals[0], ["simple", "resumable"].iter().map(|&v| v.to_string()).collect(), err);
|
||||
let protocol = calltype_from_str(vals[0], ["simple", "resumable"].iter().map(|&v| v.to_string()).collect(), err);
|
||||
let mut input_file = input_file_from_opts(vals[1], err);
|
||||
let mime_type = input_mime_from_opts(opt.value_of("mime").unwrap_or("application/octet-stream"), err);
|
||||
if dry_run {
|
||||
@@ -87,7 +90,9 @@ impl<'n, 'a> Engine<'n, 'a> {
|
||||
} {
|
||||
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
||||
Ok((mut response, output_schema)) => {
|
||||
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
||||
let mut value = json::value::to_value(&output_schema);
|
||||
remove_json_null_values(&mut value);
|
||||
serde::json::to_writer_pretty(&mut ostream, &value).unwrap();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -165,6 +170,13 @@ impl<'n, 'a> Engine<'n, 'a> {
|
||||
let engine = Engine {
|
||||
opt: opt,
|
||||
hub: api::GroupsMigration::new(client, auth),
|
||||
gp: vec!["alt", "fields", "key", "oauth-token", "pretty-print", "quota-user", "user-ip"],
|
||||
gpm: vec![
|
||||
("oauth-token", "oauth_token"),
|
||||
("pretty-print", "prettyPrint"),
|
||||
("quota-user", "quotaUser"),
|
||||
("user-ip", "userIp"),
|
||||
]
|
||||
};
|
||||
|
||||
match engine._doit(true) {
|
||||
@@ -186,29 +198,31 @@ fn main() {
|
||||
let upload_value_names = ["mode", "file"];
|
||||
let arg_data = [
|
||||
("archive", "methods: 'insert'", vec![
|
||||
("insert", Some("Inserts a new mail into the archive of the Google group."),
|
||||
("insert",
|
||||
Some(r##"Inserts a new mail into the archive of the Google group."##),
|
||||
"Details at http://byron.github.io/google-apis-rs/google_groupsmigration1_cli/archive_insert",
|
||||
vec![
|
||||
(Some("group-id"),
|
||||
(Some(r##"group-id"##),
|
||||
None,
|
||||
Some("The group ID"),
|
||||
Some(r##"The group ID"##),
|
||||
Some(true),
|
||||
Some(false)),
|
||||
|
||||
(Some("mode"),
|
||||
Some("u"),
|
||||
Some("Specify the upload protocol (simple|resumable) and the file to upload"),
|
||||
(Some(r##"mode"##),
|
||||
Some(r##"u"##),
|
||||
Some(r##"Specify the upload protocol (simple|resumable) and the file to upload"##),
|
||||
Some(true),
|
||||
Some(true)),
|
||||
|
||||
(Some("v"),
|
||||
Some("p"),
|
||||
Some("Set various fields of the request structure"),
|
||||
(Some(r##"v"##),
|
||||
Some(r##"p"##),
|
||||
Some(r##"Set various optional parameters, matching the key=value form"##),
|
||||
Some(false),
|
||||
Some(true)),
|
||||
|
||||
(Some("out"),
|
||||
Some("o"),
|
||||
Some("Specify the file into which to write the programs output"),
|
||||
(Some(r##"out"##),
|
||||
Some(r##"o"##),
|
||||
Some(r##"Specify the file into which to write the program's output"##),
|
||||
Some(false),
|
||||
Some(false)),
|
||||
]),
|
||||
@@ -245,11 +259,12 @@ fn main() {
|
||||
for &(main_command_name, ref about, ref subcommands) in arg_data.iter() {
|
||||
let mut mcmd = SubCommand::new(main_command_name).about(about);
|
||||
|
||||
for &(sub_command_name, ref desc, ref args) in subcommands {
|
||||
for &(sub_command_name, ref desc, url_info, ref args) in subcommands {
|
||||
let mut scmd = SubCommand::new(sub_command_name);
|
||||
if let &Some(desc) = desc {
|
||||
scmd = scmd.about(desc);
|
||||
}
|
||||
scmd = scmd.after_help(url_info);
|
||||
|
||||
for &(ref arg_name, ref flag, ref desc, ref required, ref multi) in args {
|
||||
let arg_name_str =
|
||||
|
||||
Reference in New Issue
Block a user