{%- set types = { 'uint8': 'u8', 'uint16': 'u16', 'uint32': 'u32', 'int8': 'i8', 'int16': 'i16', 'int32': 'i32', 'string': 'str', 'hex': 'hex', 'uint8opt': '[u8]', 'uint16opt': '[u16]', 'uint32opt': '[u32]', 'int8opt': '[i8]', 'int16opt': '[i16]', 'int32opt': '[i32]', 'stringopt': '[str]', 'hexopt': '[hex]', 'additional': '+', 'wildcard': '*', } %}

CLI Command Reference

{% macro render_command(cmd, group=None, group_alias=None) -%} {%- if cmd.shortcuts %} {%- if group_alias %} {% set alias = group_alias + ' ' + cmd.shortcuts[0].name|string %} {%- else %} {% set alias = cmd.shortcuts[0].name|string %} {%- endif %} {%- else %} {%- if group_alias %} {% set alias = group_alias + ' ' + cmd.name|string %} {%- else %} {% set alias = cmd.name|string %} {%- endif %} {%- endif %} {%- if group %} {% set name = group + ' ' + cmd.name|string %} {%- else %} {% set name = cmd.name|string %} {%- endif %}
{{name}} {%- for arg in cmd.argument %} {{types[arg.type.lower()]}} {%- endfor %} {{cmd.handler}}
{{cmd.help}}
{% if alias != name %}
Alias {{alias}}
{% endif %} {% if cmd.argument %}
Arguments
    {%- for arg in cmd.argument %}
  • {{types[arg.type.lower()].lstrip('[').rstrip(']')}} {%- if arg.type.lower().endswith('opt') %}(optional) {% endif %} {%- if arg.help %}{{arg.help}}{% endif %} {%- if arg.type.lower() == 'additional' %} (zero or more of previous argument){% endif %} {%- if arg.type.lower() == 'wildcard' %} (zero or more arbitrary arguments){% endif %}
  • {%- endfor %}
{% endif %}
{%- endmacro %}
{%- for command in cli_command | rejectattr('group') %} {{ render_command(command) }} {%- endfor %} {%- set already_handled = [] -%} {# Iterate through all groups that aren't part of a group (i.e. top level groups) #} {%- set current_group = namespace(name='', alias='') %} {%- for group in cli_group | rejectattr('group') recursive -%} {%- if group.name not in already_handled %} {%- set current_group.name = current_group.name + ' ' + group.name %} {%- if group.shortcuts %} {%- set current_group.alias = current_group.alias + ' ' + group.shortcuts[0].name %} {%- else %} {%- set current_group.alias = current_group.alias + ' ' + group.name %} {%- endif %}
{{current_group.name}}
{% if group.help %}{{group.help}}{% endif %} {# {% if current_group.alias != current_group.name %}
Alias {{current_group.alias}}
{% endif %} #}
{%- for command in cli_command if command.group == group.name %} {{ render_command(command, group=current_group.name, group_alias=current_group.alias) }} {%- endfor %} {# Check if any other group reference this group #} {%- set outer_loop = loop -%} {%- for sub_group in cli_group if sub_group.group and sub_group.group == group.name -%} {%- if sub_group.name not in already_handled and sub_group.name -%} {{ outer_loop([sub_group]) }} {%- endif -%} {%- endfor -%}
{%- if already_handled.append(group.name) -%} {# This block does nothing, it only exists to append to already_handled. #} {%- endif %} {%- set current_group.name = '' %} {%- set current_group.alias = '' %}
{%- endif %}{# group.name not in already_handled #} {%- endfor -%}