docs(CLI): add required scalar arguments

This commit is contained in:
Sebastian Thiel
2015-04-12 18:16:53 +02:00
parent 334061a5e2
commit c65a8a6bdf
3 changed files with 29 additions and 11 deletions

View File

@@ -37,6 +37,9 @@ def pretty(n):
return ' '.join(s.capitalize() for s in mangle_subcommand(n).split('-'))
def is_request_value_property(mc, p):
return mc.request_value and mc.request_value.id == p.get(util.TREF)
# transform name to be a suitable subcommand
def mangle_subcommand(name):
return util.camel_to_under(name).replace('_', '-').replace('.', '-')

View File

@@ -2,7 +2,7 @@
<%!
from util import (put_and, supports_scopes)
from cli import (mangle_subcommand, new_method_context, PARAM_FLAG, STRUCT_FLAG, UPLOAD_FLAG, OUTPUT_FLAG, VALUE_ARG,
CONFIG_DIR, SCOPE_FLAG)
CONFIG_DIR, SCOPE_FLAG, is_request_value_property)
v_arg = '<%s>' % VALUE_ARG
file_arg = '<file>'
@@ -24,10 +24,11 @@ Usage:
mc = new_method_context(resource, method, c)
args = list()
if mc.optional_props or parameters is not UNDEFINED:
args.append('[-%s %s]...' % (PARAM_FLAG, v_arg))
param_used = True
# end paramters
for p in mc.required_props:
if is_request_value_property(mc, p):
continue
args.append('<%s>' % mangle_subcommand(p.name))
# end for each required property
if mc.request_value:
args.append('-%s %s...' % (STRUCT_FLAG, v_arg))
@@ -43,6 +44,11 @@ Usage:
upload_protocols_used = upload_protocols_used|set(upload_protocols)
# end upload handling
if mc.optional_props or parameters is not UNDEFINED:
args.append('[-%s %s]...' % (PARAM_FLAG, v_arg))
param_used = True
# end paramters
if mc.response_schema:
args.append('[-%s %s]' % (OUTPUT_FLAG, out_arg))
output_used = True
@@ -55,9 +61,6 @@ Usage:
% if param_used|struct_used|output_used or upload_protocols_used:
Options:
% if param_used:
-${PARAM_FLAG} ${v_arg} set optional request parameter; ${v_arg} is of form 'name=value'
% endif
% if struct_used:
-${STRUCT_FLAG} ${v_arg} set request structure field;
${v_arg} supports cursor form 'field[:subfield]...' to
@@ -71,6 +74,9 @@ Options:
${mime_arg} the mime type, like 'application/octet-stream',
which is the default
% endif
% if param_used:
-${PARAM_FLAG} ${v_arg} set optional request parameter; ${v_arg} is of form 'name=value'
% endif
% if output_used:
-${OUTPUT_FLAG} ${out_arg}
The `destination` to which to write the server result to.