From 70274d69e9b118ba52dfcd891eadf9a2e5602b90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 25 Aug 2025 15:44:03 +0200 Subject: [PATCH] =?UTF-8?q?templates/list:=20=E2=80=9CLast=20input?= =?UTF-8?q?=E2=80=9D=20detection=20is=20off=20when=20some=20inputs=20don?= =?UTF-8?q?=E2=80=99t=20define=20this=20template=5Ftype.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit is_last_input compares against len(templates.custom.items()) - 1, but you continue past inputs that lack template_type, so the ASCII tree may render └ on non-final printed items. Compute the filtered inputs list first. --- pkgs/clan-cli/clan_cli/templates/list.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/templates/list.py b/pkgs/clan-cli/clan_cli/templates/list.py index eeccf0cb4..56f3be8a4 100644 --- a/pkgs/clan-cli/clan_cli/templates/list.py +++ b/pkgs/clan-cli/clan_cli/templates/list.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import argparse import logging from typing import TYPE_CHECKING @@ -32,17 +34,15 @@ def list_command(args: argparse.Namespace) -> None: else: print(f"│ └── {name}: {description}") - for input_idx, (input_name, input_templates) in enumerate( - templates.custom.items(), - ): - custom_templates: TemplateClanType | None = input_templates.get( - template_type, - None, - ) # type: ignore - if not custom_templates: - continue - - is_last_input = input_idx == len(templates.custom.items()) - 1 + visible_inputs = [ + (input_name, input_templates) + for input_name, input_templates in templates.custom.items() + if template_type in input_templates + ] + last_idx = len(visible_inputs) - 1 + for input_idx, (input_name, input_templates) in enumerate(visible_inputs): + custom_templates: TemplateClanType = input_templates[template_type] # type: ignore + is_last_input = input_idx == last_idx prefix = "│" if not is_last_input else " " if not is_last_input: print(f"├── inputs.{input_name}:")