From 0bb30da78244abcf09c7d04571515e6584ccb4a3 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sat, 25 Apr 2015 13:32:03 +0200 Subject: [PATCH] fix(CLI): use only one request structure This works as we can just put all request-structure parsing to the top of the function. That way, we don't put the request struture twice. --- src/mako/cli/lib/engine.mako | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/mako/cli/lib/engine.mako b/src/mako/cli/lib/engine.mako index 2b4c2d4bdb1..f598f64899f 100644 --- a/src/mako/cli/lib/engine.mako +++ b/src/mako/cli/lib/engine.mako @@ -175,7 +175,7 @@ if opt.flag_${flag_name} { %>\ % if is_request_value_property(mc, p): <% request_prop_type = prop_type %>\ -let ${prop_name} = api::${prop_type}::default(); +${self._request_value_impl(c, request_cli_schema, prop_name, request_prop_type)}\ % elif p.type != 'string': % if p.get('repeated', False): let ${prop_name}: Vec<${prop_type} = Vec::new(); @@ -259,9 +259,6 @@ ${value_unwrap}\ } } % endif # handle call parameters -% if mc.request_value: -${self._request_value_impl(c, request_cli_schema, request_prop_type)}\ -% endif # handle struct parsing % if mc.media_params: let protocol = % for p in mc.media_params: @@ -337,7 +334,7 @@ if dry_run { }\ -<%def name="_request_value_impl(c, request_cli_schema, request_prop_type)"> +<%def name="_request_value_impl(c, request_cli_schema, request_prop_name, request_prop_type)"> <% allow_optionals_fn = lambda s: is_schema_with_optionals(schema_markers(s, c, transitive=False)) @@ -384,7 +381,7 @@ if dry_run { init_fn_map = dict() flatten_schema_fields(request_cli_schema, schema_fields, init_fn_map) %>\ -let mut request = api::${request_prop_type}::default(); +let mut ${request_prop_name} = api::${request_prop_type}::default(); let mut field_name = FieldCursor::default(); for kvarg in ${SOPT + arg_ident(KEY_VALUE_ARG)}.iter() { let (key, value) = parse_kv_arg(&*kvarg, err, false); @@ -446,5 +443,4 @@ ${opt_suffix}\ } } } -call = call.request(request); \ No newline at end of file