From 0c14fc3a211fc6ba55cf58c1b8224700102a33b3 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Wed, 29 Jan 2025 19:22:05 +0000 Subject: Resolve keyboard_aliases when processing keyboard make targets (#24834) --- lib/python/qmk/cli/__init__.py | 1 + lib/python/qmk/cli/resolve_alias.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 lib/python/qmk/cli/resolve_alias.py (limited to 'lib/python') diff --git a/lib/python/qmk/cli/__init__.py b/lib/python/qmk/cli/__init__.py index 2d63dfb447..bb47ea26ed 100644 --- a/lib/python/qmk/cli/__init__.py +++ b/lib/python/qmk/cli/__init__.py @@ -82,6 +82,7 @@ subcommands = [ 'qmk.cli.new.keymap', 'qmk.cli.painter', 'qmk.cli.pytest', + 'qmk.cli.resolve_alias', 'qmk.cli.test.c', 'qmk.cli.userspace.add', 'qmk.cli.userspace.compile', diff --git a/lib/python/qmk/cli/resolve_alias.py b/lib/python/qmk/cli/resolve_alias.py new file mode 100644 index 0000000000..b9ffb46618 --- /dev/null +++ b/lib/python/qmk/cli/resolve_alias.py @@ -0,0 +1,16 @@ +from qmk.keyboard import keyboard_folder + +from milc import cli + + +@cli.argument('--allow-unknown', arg_only=True, action='store_true', help="Return original if rule is not a valid keyboard.") +@cli.argument('keyboard', arg_only=True, help='The keyboard\'s name') +@cli.subcommand('Resolve DEFAULT_FOLDER and any keyboard_aliases for provided rule') +def resolve_alias(cli): + try: + print(keyboard_folder(cli.args.keyboard)) + except ValueError: + if cli.args.allow_unknown: + print(cli.args.keyboard) + else: + raise -- cgit v1.2.3