{% import 'click_web/form_macros.html' as macros %}
<h2 class="command-title-parents">{{ levels[1:-1]| join(' - ', attribute='command.name')|title }}</h2>
<h3 class="command-title">{{ command.name|title }}</h3>
<div class="command-help">{{ command.html_help }}</div>

<form id="inputform"
      method="post"
      action="{{ request.url }}"
      onsubmit="return postAndRead('{{ request.url }}');"
      class="pure-form pure-form-aligned"
      enctype="multipart/form-data">
    {% set command_list = [] %}
    {% for level in levels %}
        {% for field in level.fields %}
            <div class="parameter {{ field.param }} {{ field.type }}">
                <div class="pure-control-group">
                    {% if field.nargs == -1 %}
                        {{ macros.add_variadic_field_input(field) }}
                    {% else %}
                        <label for="{{ field.name }}">
                            {{ field.human_readable_name|capitalize }}
                        </label>
                        {% for arg in range(field.nargs) %}
                            {{ macros.add_field_input(field) }}
                        {% endfor %}

                    {% endif %}
                </div>
            </div>
        {% endfor %}
    {% endfor %}
    <button type="submit" id="submit_btn" class="btn btn-primary m-2">Run</button>
</form>

<div id="output-header" hidden="true"></div>
<div class="script-output" id="output" hidden="true"></div>
<div id="output-footer" hidden="true"></div>
