{% macro renderSyntax(container, prefix) -%} {% for name in container.names %} ng {%if prefix %}{$ prefix $} {% endif %}{$ name $} {%- for arg in container.positionalOptions %} <{$ arg.name $}>{% endfor %} {%- if container.namedOptions.length %} [options]{% endif -%} {% endfor %} {% endmacro %} {% macro renderArguments(arguments, level = 2) %} {% if arguments.length %} Arguments {% for option in arguments %} {% endfor %}
Argument Description
<{$ option.name $}> {$ option.description | marked $} {% if option.subcommands.length -%}

This option can take one of the following sub-commands:

{%- endif %}
{% endif %} {% endmacro %} {% macro renderNamedOptions(options, level = 2) %} {% if options.length %} Options {% for option in options %} {% endfor %}
Option Description
{$ renderOption(option.name, option.type, option.default, option.enum) $} {% if option.deprecated !== undefined and option.deprecated !== false %} {% if option.deprecated !== true %} {$ option.deprecated | marked $} {% endif %}{% endif %} {$ option.description | marked $} {% if option.default !== undefined %}

Default: {$ option.default $}

{% endif %} {% if option.aliases.length %}

Aliases: {% for alias in option.aliases %}{$ renderOptionName(alias) $}{% if not loop.last %}, {% endif %}{% endfor %}

{% endif %}
{% endif %} {% endmacro %} {%- macro renderOptionName(name) -%} {% if name.length > 1 %}-{% endif %}-{$ name $} {%- endmacro %} {%- macro renderValues(values, default) -%} {%- set valString = values.join('|') -%} {%- if valString.length > 15 %}
{% endif %}{$ valString $} {%- endmacro -%} {%- macro renderOption(name, type, default, values) -%} {% set prefix = '--' if name.length > 1 else '-' %} {%- if type === 'boolean' and not values.length %}{$ prefix $}{$ name $}={$ renderValues([true, false], default) $} {%- elif values.length -%} {$ prefix $}{$ name $}={$ renderValues(values, default) $} {%- elif type === 'string' -%} {$ prefix $}{$ name $}={% if name.length > 15 %}
{% endif %}{$ name $} {%- else -%} {$ prefix $}{$ name $} {%- endif -%} {%- endmacro -%} {%- macro renderSubcommands(container) -%} {% for command in container.positionalOptions %}{% if command.subcommands.length %}

{$ command.name | title $} commands

{% for subcommand in command.subcommands %}

{$ subcommand.name $}

{% for name in container.names %} {$ renderSyntax(subcommand, name) $} {% endfor %} {$ subcommand.description | marked $} {# for now we assume that commands do not have further sub-commands #} {$ renderArguments(subcommand.positionalOptions, 4) $} {$ renderNamedOptions(subcommand.namedOptions, 4) $} {% endfor %} {% endif %}{% endfor %} {%- endmacro -%}