def _set_handlers(option):
"""Render handler call for options::set()."""
- optname = option.long_name if option.long else ""
if option.handler:
if option.type == 'void':
return 'opts.handler().{}(name)'.format(option.handler)
"""Render predicate calls for options::set()."""
if option.type == 'void':
return []
- optname = option.long_name if option.long else ""
assert option.type != 'void'
res = []
if option.minimum:
TPL_MODE_DECL = '''enum class {type}
{{
- {values}
+ {values},
+ __MAX_VALUE = {maxvalue}
}};
std::ostream& operator<<(std::ostream& os, {type} mode);
{type} stringTo{type}(const std::string& optarg);
for option in module.options:
if option.name is None or not option.mode:
continue
+ values = list(option.mode.keys())
res.append(
TPL_MODE_DECL.format(type=option.type,
- values=wrap_line(
- ', '.join(option.mode.keys()), 2)))
+ values=wrap_line(', '.join(values), 2),
+ maxvalue=values[-1]))
return '\n'.join(res)