11<%namespace name =" util" file =" ../../lib/util.mako" /> \
22<%!
3- from util import (put_and, supports_scopes, api_index)
3+ from util import (put_and, supports_scopes, api_index, indent_by )
44 from cli import (mangle_subcommand, new_method_context, PARAM_FLAG , STRUCT_FLAG , UPLOAD_FLAG , OUTPUT_FLAG , VALUE_ARG ,
55 CONFIG_DIR , SCOPE_FLAG , is_request_value_property, FIELD_SEP , docopt_mode, FILE_ARG , MIME_ARG , OUT_ARG ,
66 CONFIG_DIR_FLAG , KEY_VALUE_ARG , to_docopt_arg, DEBUG_FLAG , DEBUG_AUTH_FLAG )
77%> \
8- <%def name = "new( c , usage_only = False ) "> \
8+ <%def name = "grammar( c ) "> \
99<%
1010 param_used = False
1111 struct_used = False
1212 upload_protocols_used = set ()
1313 output_used = False
1414%> \
15- % if not usage_only:
16- docopt!(Options derive Debug, "
17- Usage:
18- % endif
1915% for resource in sorted (c.rta_map.keys()):
2016 % for method in sorted (c.rta_map[resource]):
2117<%
@@ -75,7 +71,78 @@ Configuration:
7571 --${ DEBUG_AUTH_FLAG }
7672 Output all communication related to authentication to standard error. `tx`
7773 and `rx` are placed into the same stream.
78- % if not usage_only:
79- ");
80- % endif
74+ </%def >
75+
76+
77+
78+ <%def name = "new(c ) " buffered =" True" > \
79+ <%
80+ param_used = False
81+ struct_used = False
82+ upload_protocols_used = set ()
83+ output_used = False
84+ %> \
85+ App::new("${ util.program_name()} ")
86+ <%block filter =" indent_by(4)" >
87+ % for resource in sorted (c.rta_map.keys()):
88+ % for method in sorted (c.rta_map[resource]):
89+ <%
90+ mc = new_method_context(resource, method, c)
91+
92+ args = list ()
93+ for p in mc.required_props:
94+ if is_request_value_property(mc, p):
95+ continue
96+ args.append(to_docopt_arg(p))
97+ # end for each required property
98+
99+ if mc.request_value:
100+ args.append(' -%s %s ...' % (STRUCT_FLAG , ' <%s >' % KEY_VALUE_ARG ))
101+ struct_used = True
102+ # end request_value
103+
104+ if mc.media_params:
105+ upload_protocols = [mp.protocol for mp in mc.media_params]
106+ mode = docopt_mode(upload_protocols)
107+ args.append(' -%s %s %s %s ' % (UPLOAD_FLAG , mode, FILE_ARG , MIME_ARG ))
108+ upload_protocols_used = upload_protocols_used| set (upload_protocols)
109+ # end upload handling
110+
111+ if mc.optional_props or parameters is not UNDEFINED :
112+ args.append(' [-%s %s ...]' % (PARAM_FLAG , ' <%s >' % VALUE_ARG ))
113+ param_used = True
114+ # end paramters
115+
116+ if mc.response_schema or mc.m.get(' supportsMediaDownload' , False ):
117+ args.append(' [-%s %s ]' % (OUTPUT_FLAG , OUT_ARG ))
118+ output_used = True
119+ # handle output
120+ %> \
121+ ${ util.program_name()} [options] ${ mangle_subcommand(resource)} ${ mangle_subcommand(method)} ${ ' ' .join(args)}
122+ % endfor # each method
123+ % endfor # end for each resource
124+ ${ util.program_name()} --help
125+
126+ All documentation details can be found at
127+ ${ cargo.doc_base_url + ' /' + api_index(cargo.doc_base_url, name, version, make, check_exists = False )}
128+
129+ Configuration:
130+ % if supports_scopes(auth):
131+ --${ SCOPE_FLAG } <url >
132+ Specify the authentication a method should be executed in. Each scope
133+ requires the user to grant this application permission to use it.
134+ If unset, it defaults to the shortest scope url for a particular method.
135+ % endif scopes
136+ --${ CONFIG_DIR_FLAG } <folder >
137+ A directory into which we will store our persistent data. Defaults to
138+ a user-writable directory that we will create during the first invocation.
139+ [default: ${ CONFIG_DIR } ]
140+ --${ DEBUG_FLAG }
141+ Output all server communication to standard error. `tx` and `rx` are placed
142+ into the same stream.
143+ --${ DEBUG_AUTH_FLAG }
144+ Output all communication related to authentication to standard error. `tx`
145+ and `rx` are placed into the same stream.
146+ .get_matches();
147+ </%block >
81148</%def >
0 commit comments