{%- if cmd.before_help_long %}{{ cmd.before_help_long }}

{% elif cmd.before_help %}{{ cmd.before_help }}

{% elif spec.before_help_long %}{{ spec.before_help_long }}

{% elif spec.before_help %}{{ spec.before_help }}

{% endif -%}
{%- if root %}
{%- if spec.name and spec.version %}{{ spec.name }} {{ spec.version }}
{% elif spec.version %}{{ spec.bin }} {{ spec.version }}
{% endif -%}
{%- if spec.about_long %}{{ spec.about_long }}

{% elif spec.about %}{{ spec.about }}

{% endif -%}
{%- else -%}
{%- if cmd.help_long %}{{ cmd.help_long }}

{% elif cmd.help %}{{ cmd.help }}

{% endif -%}
{%- endif -%}
{%- if cmd.deprecated or cmd.deprecated_warn_at or cmd.deprecated_remove_at %}
[deprecated:{% if cmd.deprecated %} {{ cmd.deprecated }}{% endif %}{% if cmd.deprecated_warn_at %}{% if cmd.deprecated %};{% endif %} warns at {{ cmd.deprecated_warn_at }}{% endif %}{% if cmd.deprecated_remove_at %}{% if cmd.deprecated or cmd.deprecated_warn_at %};{% endif %} removed at {{ cmd.deprecated_remove_at }}{% endif %}]

{%- endif -%}{{ mark_usage }}
{%- if cmd.flatten_help and cmd.flattened_usage %}
{%- for usage in cmd.flattened_usage %}
{% if loop.first %}Usage: {% else %}       {% endif %}{{ (spec.bin ~ " " ~ usage) | trim }}
{%- endfor %}
{%- else -%}
Usage: {{ (spec.bin ~ " " ~ cmd.usage) | trim }}
{%- endif %}{{ mark_commands }}

{%- if cmd.subcommands and not cmd.flatten_help %}
{%- for group in cmd.subcommand_groups %}

{{ group.heading | default(value=cmd.subcommand_help_heading | default(value="Commands")) }}:
{%- for cmd in group.items %}
  {{ cmd.usage | trim }}
{%- if cmd.deprecated or cmd.deprecated_warn_at or cmd.deprecated_remove_at %} [deprecated:{% if cmd.deprecated %} {{ cmd.deprecated }}{% endif %}{% if cmd.deprecated_warn_at %}{% if cmd.deprecated %};{% endif %} warns at {{ cmd.deprecated_warn_at }}{% endif %}{% if cmd.deprecated_remove_at %}{% if cmd.deprecated or cmd.deprecated_warn_at %};{% endif %} removed at {{ cmd.deprecated_remove_at }}{% endif %}]{%- endif %}
{%- if cmd.aliases %} [aliases: {{ cmd.aliases | join(sep=", ") }}]{% endif %}
{%- set help = cmd.help_long | default(value=cmd.help | default(value='')) %}
{%- if help %}
    {{ help | indent(width=4) }}
{%- endif %}
{% endfor %}
{%- if not group.heading and show_help_subcommand %}
  help
    Print this message or the help of the given subcommand(s)
{%- endif %}
{%- endfor %}
{%- endif %}{{ mark_args }}

{%- for group in cmd.arg_groups %}

{{ group.heading | default(value="Arguments") }}:
{%- for arg in group.items %}
{%- if cmd.next_line_help %}
  {{ arg.usage | trim }}
{%- set help = arg.help_long | default(value=arg.help | default(value='')) %}
{%- if help %}
    {{ help | indent(width=4) }}
{%- endif %}
{%- elif arg.help_rendered %}
  {{ arg.usage | ljust(width=arg.usage_col_width) }}  {{ arg.help_rendered }}
{%- if arg.help_is_multiline %}

{%- endif %}
{%- else %}
  {{ arg.usage | trim }}
{%- set help = arg.help_long | default(value=arg.help | default(value='')) %}
{%- if help %}
    {{ help | indent(width=4) }}
{%- endif %}
{%- endif %}
{%- if not arg.hide_possible_values and arg.choices and arg.choices.choices %}
    [possible values: {{ arg.choices.choices | join(sep=", ") }}]
{%- endif %}
{%- if not arg.hide_possible_values and arg.choices and arg.choices.env %}
    [choices env: {{ arg.choices.env }}]
{%- endif %}
{%- if not arg.hide_env and arg.env %}
    [env: {{ arg.env }}]
{%- endif %}
{%- if not arg.hide_env %}{% for env in arg.env_fallback %}
    [env fallback: {{ env }}]
{%- endfor %}{% for env in arg.deprecated_env %}
    [deprecated env: {{ env }}]
{%- endfor %}{%- endif %}
{%- if not arg.hide_default_value and arg.default %}
    (default: {{ arg.default | join(sep=", ") }})
{%- endif %}
{%- endfor %}
{%- endfor %}{{ mark_flags }}

{%- for group in cmd.flag_groups %}

{{ group.heading | default(value="Flags") }}:
{%- for flag in group.items %}
{%- if cmd.next_line_help %}
  {{ flag.display_usage }}
{%- if flag.aliases %}  [aliases: {{ flag.aliases | join(sep=", ") }}]{% endif %}
{%- set help = flag.help_long | default(value=flag.help | default(value='')) %}
{%- if help %}
    {{ help | indent(width=4) }}
{%- endif %}
{%- elif flag.help_rendered %}
  {{ flag.display_usage | ljust(width=flag.usage_col_width) }}  {{ flag.help_rendered }}
{%- if flag.help_is_multiline %}

{%- endif %}
{%- else %}
  {{ flag.display_usage }}
{%- if flag.aliases %}  [aliases: {{ flag.aliases | join(sep=", ") }}]{% endif %}
{%- set help = flag.help_long | default(value=flag.help | default(value='')) %}
{%- if help %}
    {{ help | indent(width=4) }}
{%- endif %}
{%- endif %}
{%- if not flag.hide_possible_values and flag.arg.choices and flag.arg.choices.choices %}
    [possible values: {{ flag.arg.choices.choices | join(sep=", ") }}]
{%- endif %}
{%- if not flag.hide_possible_values and flag.arg.choices and flag.arg.choices.env %}
    [choices env: {{ flag.arg.choices.env }}]
{%- endif %}
{%- if not flag.hide_env and flag.env %}
    [env: {{ flag.env }}]
{%- endif %}
{%- if not flag.hide_env %}{% for env in flag.env_fallback %}
    [env fallback: {{ env }}]
{%- endfor %}{% for env in flag.deprecated_env %}
    [deprecated env: {{ env }}]
{%- endfor %}{%- endif %}
{%- if not flag.hide_default_value and flag.default %}
    (default: {{ flag.default | join(sep=", ") }})
{%- endif %}
{%- if flag.deprecated or flag.deprecated_warn_at or flag.deprecated_remove_at %}
    [deprecated:{% if flag.deprecated %} {{ flag.deprecated }}{% endif %}{% if flag.deprecated_warn_at %}{% if flag.deprecated %};{% endif %} warns at {{ flag.deprecated_warn_at }}{% endif %}{% if flag.deprecated_remove_at %}{% if flag.deprecated or flag.deprecated_warn_at %};{% endif %} removed at {{ flag.deprecated_remove_at }}{% endif %}]
{%- endif %}
{%- endfor %}
{%- endfor %}

{%- if global_flags %}

Global flags:
{%- for flag in global_flags %}
{%- if cmd.next_line_help %}
  {{ flag.display_usage }}
{%- if flag.aliases %}  [aliases: {{ flag.aliases | join(sep=", ") }}]{% endif %}
{%- set help = flag.help_long | default(value=flag.help | default(value='')) %}
{%- if help %}
    {{ help | indent(width=4) }}
{%- endif %}
{%- elif flag.help_rendered %}
  {{ flag.display_usage | ljust(width=flag.usage_col_width) }}  {{ flag.help_rendered }}
{%- if flag.help_is_multiline %}

{%- endif %}
{%- else %}
  {{ flag.display_usage }}
{%- if flag.aliases %}  [aliases: {{ flag.aliases | join(sep=", ") }}]{% endif %}
{%- set help = flag.help_long | default(value=flag.help | default(value='')) %}
{%- if help %}
    {{ help | indent(width=4) }}
{%- endif %}
{%- endif %}
{%- if not flag.hide_possible_values and flag.arg.choices and flag.arg.choices.choices %}
    [possible values: {{ flag.arg.choices.choices | join(sep=", ") }}]
{%- endif %}
{%- if not flag.hide_possible_values and flag.arg.choices and flag.arg.choices.env %}
    [choices env: {{ flag.arg.choices.env }}]
{%- endif %}
{%- if not flag.hide_env and flag.env %}
    [env: {{ flag.env }}]
{%- endif %}
{%- if not flag.hide_env %}{% for env in flag.env_fallback %}
    [env fallback: {{ env }}]
{%- endfor %}{% for env in flag.deprecated_env %}
    [deprecated env: {{ env }}]
{%- endfor %}{%- endif %}
{%- if not flag.hide_default_value and flag.default %}
    (default: {{ flag.default | join(sep=", ") }})
{%- endif %}
{%- if flag.deprecated or flag.deprecated_warn_at or flag.deprecated_remove_at %}
    [deprecated:{% if flag.deprecated %} {{ flag.deprecated }}{% endif %}{% if flag.deprecated_warn_at %}{% if flag.deprecated %};{% endif %} warns at {{ flag.deprecated_warn_at }}{% endif %}{% if flag.deprecated_remove_at %}{% if flag.deprecated or flag.deprecated_warn_at %};{% endif %} removed at {{ flag.deprecated_remove_at }}{% endif %}]
{%- endif %}
{%- endfor %}
{%- endif %}{{ mark_flattened }}

{%- if cmd.flatten_help %}
{%- for sub in cmd.flattened_subcommands %}

{{ sub.full_cmd | join(sep=" ") }}:
{%- set about = sub.help_long | default(value=sub.help | default(value='')) %}
{%- if about %}
{{ about | trim }}
{%- endif %}
{%- if sub.deprecated or sub.deprecated_warn_at or sub.deprecated_remove_at %}
[deprecated:{% if sub.deprecated %} {{ sub.deprecated }}{% endif %}{% if sub.deprecated_warn_at %}{% if sub.deprecated %};{% endif %} warns at {{ sub.deprecated_warn_at }}{% endif %}{% if sub.deprecated_remove_at %}{% if sub.deprecated or sub.deprecated_warn_at %};{% endif %} removed at {{ sub.deprecated_remove_at }}{% endif %}]
{%- endif %}
{%- for group in sub.arg_groups %}
{%- for arg in group.items %}
{%- if sub.flattened_next_line_help %}
  {{ arg.usage | trim }}
{%- set help = arg.help_long | default(value=arg.help | default(value='')) %}
{%- if help %}
    {{ help | indent(width=4) }}
{%- endif %}
{%- elif arg.help_rendered %}
  {{ arg.usage | ljust(width=arg.usage_col_width) }}  {{ arg.help_rendered }}
{%- else %}
  {{ arg.usage | trim }}
{%- endif %}
{%- if not arg.hide_possible_values and arg.choices and arg.choices.choices %}
    [possible values: {{ arg.choices.choices | join(sep=", ") }}]
{%- endif %}
{%- if not arg.hide_env and arg.env %}
    [env: {{ arg.env }}]
{%- endif %}
{%- if not arg.hide_env %}{% for env in arg.env_fallback %}
    [env fallback: {{ env }}]
{%- endfor %}{% for env in arg.deprecated_env %}
    [deprecated env: {{ env }}]
{%- endfor %}{%- endif %}
{%- if not arg.hide_default_value and arg.default %}
    (default: {{ arg.default | join(sep=", ") }})
{%- endif %}
{%- endfor %}
{%- endfor %}
{%- for group in sub.flag_groups %}
{%- for flag in group.items %}
{%- if sub.flattened_next_line_help %}
  {{ flag.display_usage }}
{%- set help = flag.help_long | default(value=flag.help | default(value='')) %}
{%- if help %}
    {{ help | indent(width=4) }}
{%- endif %}
{%- elif flag.help_rendered %}
  {{ flag.display_usage | ljust(width=flag.usage_col_width) }}  {{ flag.help_rendered }}
{%- else %}
  {{ flag.display_usage }}
{%- endif %}
{%- if not flag.hide_possible_values and flag.arg.choices and flag.arg.choices.choices %}
    [possible values: {{ flag.arg.choices.choices | join(sep=", ") }}]
{%- endif %}
{%- if not flag.hide_env and flag.env %}
    [env: {{ flag.env }}]
{%- endif %}
{%- if not flag.hide_env %}{% for env in flag.env_fallback %}
    [env fallback: {{ env }}]
{%- endfor %}{% for env in flag.deprecated_env %}
    [deprecated env: {{ env }}]
{%- endfor %}{%- endif %}
{%- if not flag.hide_default_value and flag.default %}
    (default: {{ flag.default | join(sep=", ") }})
{%- endif %}
{%- if flag.deprecated or flag.deprecated_warn_at or flag.deprecated_remove_at %}
    [deprecated:{% if flag.deprecated %} {{ flag.deprecated }}{% endif %}{% if flag.deprecated_warn_at %}{% if flag.deprecated %};{% endif %} warns at {{ flag.deprecated_warn_at }}{% endif %}{% if flag.deprecated_remove_at %}{% if flag.deprecated or flag.deprecated_warn_at %};{% endif %} removed at {{ flag.deprecated_remove_at }}{% endif %}]
{%- endif %}
{%- endfor %}
{%- endfor %}
{%- endfor %}
{%- endif %}{{ mark_after_help }}

{%- if cmd.examples %}

Examples:
{%- for example in cmd.examples %}
{%- if example.header %}
  {{ example.header }}:
{%- endif %}
{%- if example.help %}
    {{ example.help }}
{%- endif %}
    $ {{ example.code }}
{%- endfor %}
{%- elif spec.examples %}

Examples:
{%- for example in spec.examples %}
{%- if example.header %}
  {{ example.header }}:
{%- endif %}
{%- if example.help %}
    {{ example.help }}
{%- endif %}
    $ {{ example.code }}
{%- endfor %}
{%- endif %}

{%- if cmd.after_help_long %}

{{ cmd.after_help_long }}
{%- elif cmd.after_help %}

{{ cmd.after_help }}
{%- elif spec.after_help_long %}

{{ spec.after_help_long }}
{%- elif spec.after_help %}

{{ spec.after_help }}
{%- endif %}

{%- if spec.author or spec.license %}
{% if spec.author %}
Author: {{ spec.author }}
{%- endif %}
{%- if spec.license %}
License: {{ spec.license }}
{%- endif %}
{%- endif -%}
