From decf34025812693edccd848a974bdd2a17c30a2a Mon Sep 17 00:00:00 2001 From: Qubasa Date: Tue, 4 Feb 2025 14:28:56 +0700 Subject: [PATCH] clan-cli: Fix incorrect input handling in get_templates --- pkgs/clan-cli/clan_cli/clan/create.py | 6 +++++- pkgs/clan-cli/clan_cli/machines/create.py | 6 +++++- pkgs/clan-cli/clan_cli/templates.py | 4 +++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/clan/create.py b/pkgs/clan-cli/clan_cli/clan/create.py index fc3363903..f949f9a4a 100644 --- a/pkgs/clan-cli/clan_cli/clan/create.py +++ b/pkgs/clan-cli/clan_cli/clan/create.py @@ -113,9 +113,10 @@ def register_create_parser(parser: argparse.ArgumentParser) -> None: type=str, help="""Flake input name to use as template source can be specified multiple times, inputs are tried in order of definition + Example: --input clan --input clan-core """, action="append", - default=["clan-core"], + default=[], ) parser.add_argument( @@ -147,6 +148,9 @@ def register_create_parser(parser: argparse.ArgumentParser) -> None: ) def create_flake_command(args: argparse.Namespace) -> None: + if len(args.input) == 0: + args.input = ["clan", "clan-core"] + if args.no_self: input_prio = InputPrio.try_inputs(tuple(args.input)) else: diff --git a/pkgs/clan-cli/clan_cli/machines/create.py b/pkgs/clan-cli/clan_cli/machines/create.py index bc5e8f778..d145dd6ef 100644 --- a/pkgs/clan-cli/clan_cli/machines/create.py +++ b/pkgs/clan-cli/clan_cli/machines/create.py @@ -136,6 +136,9 @@ def create_command(args: argparse.Namespace) -> None: ) raise ClanError(msg, description=description) + if len(args.input) == 0: + args.input = ["clan", "clan-core"] + if args.no_self: input_prio = InputPrio.try_inputs(tuple(args.input)) else: @@ -185,9 +188,10 @@ def register_create_parser(parser: argparse.ArgumentParser) -> None: type=str, help="""Flake input name to use as template source can be specified multiple times, inputs are tried in order of definition + Example: --input clan --input clan-core """, action="append", - default=["clan-core"], + default=[], ) parser.add_argument( "--no-self", diff --git a/pkgs/clan-cli/clan_cli/templates.py b/pkgs/clan-cli/clan_cli/templates.py index 29e307d14..196d9c766 100644 --- a/pkgs/clan-cli/clan_cli/templates.py +++ b/pkgs/clan-cli/clan_cli/templates.py @@ -237,7 +237,9 @@ def get_template( input_name = InputName(input_name_str) log.debug(f"Checking input '{input_name}' for template '{template_name}'") - template = find_template(template_name, template_list.inputs[input_name]) + template = find_template( + template_name, template_list.inputs.get(input_name, {}) + ) if template: log.debug(f"Found template '{template_name}' in input '{input_name}'") break # Stop searching once the template is found