feat(CLI): struct value parsing

This works already for simple request values, but doens't generate
compiling code for structures with Parts in them.
Nonetheless, it's a big step towards finishing the overall issue.

Related to #64
This commit is contained in:
Sebastian Thiel
2015-04-16 17:44:30 +02:00
parent 1dd1fcf4b8
commit 15b78cd1ff
5 changed files with 111 additions and 34 deletions

View File

@@ -168,21 +168,24 @@ ${SPLIT_END}
for (fndfi, v) in enumerate(cursor):
if v != FIELD_SEP:
break
return '-%s %s ' % (STRUCT_FLAG, ''.join(cursor[:fndfi]) + FIELD_SEP.join(cursor[fndfi:]))
res = ''.join(cursor[:fndfi]) + FIELD_SEP.join(cursor[fndfi:])
if not res.endswith(FIELD_SEP):
res += FIELD_SEP
return res
def cursor_arg():
def cursor_arg(field):
prefix = ''
if cursor_tokens:
res = cursor_fmt(cursor_tokens)
prefix = cursor_fmt(cursor_tokens)
del cursor_tokens[:]
return res
return ''
return prefix + field
%>\
% for fn in sorted(schema.fields.keys()):
<%
f = schema.fields[fn]
%>\
% if isinstance(f, SchemaEntry):
* **${cursor_arg()}-${STRUCT_FLAG} ${mangle_subcommand(fn)}=${field_to_value(f)}**
* **-${STRUCT_FLAG} ${cursor_arg(mangle_subcommand(fn))}=${field_to_value(f)}**
- ${f.property.get('description', NO_DESC) | xml_escape, indent_all_but_first_by(2)}
% if f.container_type == CTYPE_ARRAY:
- Each invocation of this argument appends the given value to the array.