{#-
CLI Command Arguments Component

Renders command arguments using the unified parameter table.
Handles positional arguments with safe error boundaries.
-#}

{% from 'macros/safe_macros.md.jinja2' import safe_render, safe_for %}
{% from 'macros/parameter_table.md.jinja2' import cli_arguments %}

{% set arguments = element.children | selectattr('element_type', 'equalto', 'argument') | list %}

{% if arguments %}
## Arguments

{% call(current_item) safe_for(arguments, "*No arguments required.*") %}
{% call safe_render("argument", current_item) %}
### `{{ current_item.name }}`

{% if current_item.description %}
{{ current_item.description }}
{% else %}
*No description provided.*
{% endif %}

{% if current_item.metadata.type %}
**Type:** `{{ current_item.metadata.type }}`
{% endif %}

{% if current_item.metadata.default %}
{% set default_str = current_item.metadata.default | string %}
{% if default_str and default_str not in ['None', '', 'null'] and 'Sentinel' not in default_str %}
**Default:** `{{ current_item.metadata.default }}`
{% endif %}
{% endif %}

{% if current_item.metadata.required %}
:::{note}
This argument is required.
:::
{% else %}
:::{info}
This argument is optional.
:::
{% endif %}

{% if current_item.metadata.multiple %}
:::{info}
This argument accepts multiple values.
:::
{% endif %}

{% if current_item.metadata.choices %}
**Choices:** {% for choice in current_item.metadata.choices %}`{{ choice }}`{% if not loop.last %}, {% endif %}{% endfor %}
{% endif %}

{% endcall %}
{% endcall %}
{% endif %}
