From 20f81af98af26d3e15277e402a364a513f986aa6 Mon Sep 17 00:00:00 2001 From: Zach White Date: Mon, 4 Oct 2021 09:26:19 -0700 Subject: Allow community layouts to be specified in info.json (#14682) * move the community layout detection to python * fixup tests --- lib/python/qmk/cli/__init__.py | 1 + lib/python/qmk/cli/generate/rules_mk.py | 2 +- lib/python/qmk/cli/list/layouts.py | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 lib/python/qmk/cli/list/layouts.py (limited to 'lib') diff --git a/lib/python/qmk/cli/__init__.py b/lib/python/qmk/cli/__init__.py index f45e33240c..539d03e2fc 100644 --- a/lib/python/qmk/cli/__init__.py +++ b/lib/python/qmk/cli/__init__.py @@ -60,6 +60,7 @@ subcommands = [ 'qmk.cli.lint', 'qmk.cli.list.keyboards', 'qmk.cli.list.keymaps', + 'qmk.cli.list.layouts', 'qmk.cli.kle2json', 'qmk.cli.multibuild', 'qmk.cli.new.keyboard', diff --git a/lib/python/qmk/cli/generate/rules_mk.py b/lib/python/qmk/cli/generate/rules_mk.py index cdf17dfbcb..dcaff29fae 100755 --- a/lib/python/qmk/cli/generate/rules_mk.py +++ b/lib/python/qmk/cli/generate/rules_mk.py @@ -26,7 +26,7 @@ def process_mapping_rule(kb_info_json, rules_key, info_dict): except KeyError: return None - if key_type == 'array': + if key_type in ['array', 'list']: return f'{rules_key} ?= {" ".join(rules_value)}' elif key_type == 'bool': return f'{rules_key} ?= {"on" if rules_value else "off"}' diff --git a/lib/python/qmk/cli/list/layouts.py b/lib/python/qmk/cli/list/layouts.py new file mode 100644 index 0000000000..8e07afeeca --- /dev/null +++ b/lib/python/qmk/cli/list/layouts.py @@ -0,0 +1,18 @@ +"""List the keymaps for a specific keyboard +""" +from milc import cli + +from qmk.decorators import automagic_keyboard +from qmk.keyboard import keyboard_completer, keyboard_folder +from qmk.info import info_json + + +@cli.argument("-kb", "--keyboard", type=keyboard_folder, completer=keyboard_completer, help="Specify keyboard name. Example: monarch") +@cli.subcommand("List the layouts for a specific keyboard") +@automagic_keyboard +def list_layouts(cli): + """List the layouts for a specific keyboard + """ + info_data = info_json(cli.config.list_layouts.keyboard) + for name in sorted(info_data.get('community_layouts', [])): + print(name) -- cgit v1.2.3