mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-02-23 15:49:49 +01:00
feat(CLI): --debug flag to output traffix
* If `--debug` is set, we will output all server communication to stderr. That way, we can compare our requests to what is expected by ush based on official docs. * `discovery` now doesn't use the API key anymore - this is specified using a custom override. Nice, we are totally ready to test and fix all API features. Related to #70
This commit is contained in:
3
etc/api/discovery/v1/discovery-api_overrides.json
Normal file
3
etc/api/discovery/v1/discovery-api_overrides.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"no_auth": 1
|
||||
}
|
||||
@@ -29,5 +29,6 @@ cargo:
|
||||
- docopt = "*"
|
||||
- docopt_macros = "*"
|
||||
- rustc-serialize = "*"
|
||||
- yup-hyper-mock = "*"
|
||||
- serde = ">= 0.3.0"
|
||||
- serde_macros = "*"
|
||||
|
||||
@@ -325,7 +325,7 @@ ${capture(lib.test_hub, hub_type_name, comments=show_all) | hide_filter}
|
||||
// As the method needs a request, you would usually fill it with the desired information
|
||||
// into the respective structure. Some of the parts shown here might not be applicable !
|
||||
// ${random_value_warning}
|
||||
let mut ${rb_name}: ${request_value_type} = Default::default();
|
||||
let mut ${rb_name} = ${request_value_type}::default();
|
||||
% for spn, sp in request_value.get('properties', dict()).iteritems():
|
||||
% if parts is not None and spn not in parts:
|
||||
<% continue %>
|
||||
@@ -579,6 +579,7 @@ else {
|
||||
let mut url = "${baseUrl}${m.path}".to_string();
|
||||
% endif
|
||||
% if not default_scope:
|
||||
% if no_auth is UNDEFINED:
|
||||
<%
|
||||
assert 'key' in parameters, "Expected 'key' parameter if there are no scopes"
|
||||
%>
|
||||
@@ -593,6 +594,7 @@ else {
|
||||
return Err(Error::MissingAPIKey)
|
||||
}
|
||||
}
|
||||
% endif
|
||||
% else:
|
||||
if self.${api.properties.scopes}.len() == 0 {
|
||||
self.${api.properties.scopes}.insert(${scope_url_to_variant(name, default_scope, fully_qualified=True)}.as_ref().to_string(), ());
|
||||
|
||||
@@ -66,5 +66,8 @@ Configuration:
|
||||
A directory into which we will store our persistent data. Defaults to a user-writable
|
||||
directory that we will create during the first invocation.
|
||||
[default: ${CONFIG_DIR}]
|
||||
--debug
|
||||
Output all server communication to standard error. `tx` and `rx` are placed into
|
||||
the same stream.
|
||||
");
|
||||
</%def>
|
||||
@@ -112,9 +112,18 @@ self.opt.${cmd_ident(method)} {
|
||||
program_name: "${util.program_name()}",
|
||||
db_dir: config_dir.clone(),
|
||||
}, None);
|
||||
|
||||
let client =
|
||||
if opt.flag_debug {
|
||||
hyper::Client::with_connector(mock::TeeConnector {
|
||||
connector: hyper::net::HttpConnector(None)
|
||||
})
|
||||
} else {
|
||||
hyper::Client::new()
|
||||
};
|
||||
let engine = Engine {
|
||||
opt: opt,
|
||||
hub: ${hub_type_name}::new(hyper::Client::new(), auth),
|
||||
hub: ${hub_type_name}::new(client, auth),
|
||||
};
|
||||
|
||||
match engine._doit(true) {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
extern crate docopt;
|
||||
extern crate yup_oauth2 as oauth2;
|
||||
extern crate yup_hyper_mock as mock;
|
||||
extern crate rustc_serialize;
|
||||
extern crate serde;
|
||||
extern crate hyper;
|
||||
@@ -33,12 +34,13 @@ fn main() {
|
||||
let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit());
|
||||
match Engine::new(opts) {
|
||||
Err(err) => {
|
||||
write!(io::stderr(), "{}", err).ok();
|
||||
writeln!(io::stderr(), "{}", err).ok();
|
||||
env::set_exit_status(err.exit_code);
|
||||
},
|
||||
Ok(engine) => {
|
||||
if let Some(err) = engine.doit() {
|
||||
write!(io::stderr(), "{}", err).ok();
|
||||
writeln!(io::stderr(), "{:?}", err).ok();
|
||||
writeln!(io::stderr(), "{}", err).ok();
|
||||
env::set_exit_status(1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user