Skip to content

Commit 03f35bd

Browse files
committed
feat(CLI): --debug-auth flag
* Allow to see all authentication related communication, similar to --debug flag otherwise. * fixed broken generator when handling request value parsing. Fixes #70
1 parent 159c659 commit 03f35bd

2 files changed

Lines changed: 22 additions & 15 deletions

File tree

src/mako/cli/lib/docopt.mako

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,8 @@ Configuration:
6969
--debug
7070
Output all server communication to standard error. `tx` and `rx` are placed into
7171
the same stream.
72+
--debug-auth
73+
Output all communication related to authentication to standard error. `tx` and `rx` are placed into
74+
the same stream.
7275
");
7376
</%def>

src/mako/cli/lib/engine.mako

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,21 +106,15 @@ self.opt.${cmd_ident(method)} {
106106
}
107107
};
108108
109-
let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
110-
hyper::Client::new(),
111-
JsonTokenStorage {
112-
program_name: "${util.program_name()}",
113-
db_dir: config_dir.clone(),
114-
}, None);
109+
let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate,
110+
${self._debug_client('debug_auth') | indent_all_but_first_by(10)},
111+
JsonTokenStorage {
112+
program_name: "${util.program_name()}",
113+
db_dir: config_dir.clone(),
114+
}, None);
115115
116116
let client =
117-
if opt.flag_debug {
118-
hyper::Client::with_connector(mock::TeeConnector {
119-
connector: hyper::net::HttpConnector(None)
120-
})
121-
} else {
122-
hyper::Client::new()
123-
};
117+
${self._debug_client('debug') | indent_all_but_first_by(3)};
124118
let engine = Engine {
125119
opt: opt,
126120
hub: ${hub_type_name}::new(client, auth),
@@ -140,6 +134,16 @@ self.opt.${cmd_ident(method)} {
140134
}
141135
</%def>
142136

137+
<%def name="_debug_client(flag_name)" buffered="True">\
138+
if opt.flag_${flag_name} {
139+
hyper::Client::with_connector(mock::TeeConnector {
140+
connector: hyper::net::HttpConnector(None)
141+
})
142+
} else {
143+
hyper::Client::new()
144+
}\
145+
</%def>
146+
143147
<%def name="_method_call_impl(c, resource, method)" buffered="True">\
144148
<%
145149
mc = new_method_context(resource, method, c)
@@ -247,7 +251,7 @@ ${value_unwrap}\
247251
}
248252
% endif # handle call parameters
249253
% if mc.request_value:
250-
${self._request_value_impl(c, request_cli_schema)}\
254+
${self._request_value_impl(c, request_cli_schema, request_prop_type)}\
251255
% endif # handle struct parsing
252256
% if mc.media_params:
253257
let protocol =
@@ -319,7 +323,7 @@ if dry_run {
319323
}\
320324
</%def>
321325

322-
<%def name="_request_value_impl(c, request_cli_schema)">
326+
<%def name="_request_value_impl(c, request_cli_schema, request_prop_type)">
323327
<%
324328
allow_optionals_fn = lambda s: is_schema_with_optionals(schema_markers(s, c, transitive=False))
325329

0 commit comments

Comments
 (0)