diff options
author | Nick Brassel <[email protected]> | 2024-05-28 14:39:23 +1000 |
---|---|---|
committer | Nick Brassel <[email protected]> | 2024-05-28 14:39:23 +1000 |
commit | f76cc320fd9f3365a80cc0d8af2990bc28d76bde (patch) | |
tree | 3c5330bbc9ab254424ac57335510de341b4ada11 /lib/python/qmk/cli/new/keyboard.py | |
parent | 7620c64b99dc5bec480bfaa2708cb3fae709e2b3 (diff) | |
parent | 465ab5a20643722c9b712c6b6924472b7345dd64 (diff) | |
download | qmk_firmware-f76cc320fd9f3365a80cc0d8af2990bc28d76bde.tar.gz qmk_firmware-f76cc320fd9f3365a80cc0d8af2990bc28d76bde.zip |
Merge branch 'develop'0.25.0
Diffstat (limited to 'lib/python/qmk/cli/new/keyboard.py')
-rw-r--r-- | lib/python/qmk/cli/new/keyboard.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/python/qmk/cli/new/keyboard.py b/lib/python/qmk/cli/new/keyboard.py index cb50acf8bb..37bf2923d6 100644 --- a/lib/python/qmk/cli/new/keyboard.py +++ b/lib/python/qmk/cli/new/keyboard.py @@ -74,6 +74,10 @@ def replace_placeholders(src, dest, tokens): dest.write_text(content) +def replace_string(src, token, value): + src.write_text(src.read_text().replace(token, value)) + + def augment_community_info(src, dest): """Splice in any additional data into info.json """ @@ -218,6 +222,11 @@ def new_keyboard(cli): else: bootloader = select_default_bootloader(mcu) + detach_layout = False + if default_layout == 'none of the above': + default_layout = "ortho_4x4" + detach_layout = True + tokens = { # Comment here is to force multiline formatting 'YEAR': str(date.today().year), 'KEYBOARD': kb_name, @@ -233,10 +242,6 @@ def new_keyboard(cli): for key, value in tokens.items(): cli.echo(f" {key.ljust(10)}: {value}") - # TODO: detach community layout and rename to just "LAYOUT" - if default_layout == 'none of the above': - default_layout = "ortho_4x4" - # begin with making the deepest folder in the tree keymaps_path = keyboard(kb_name) / 'keymaps/' keymaps_path.mkdir(parents=True) @@ -251,7 +256,12 @@ def new_keyboard(cli): # merge in infos community_info = Path(COMMUNITY / f'{default_layout}/info.json') - augment_community_info(community_info, keyboard(kb_name) / community_info.name) + augment_community_info(community_info, keyboard(kb_name) / 'keyboard.json') + + # detach community layout and rename to just "LAYOUT" + if detach_layout: + replace_string(keyboard(kb_name) / 'keyboard.json', 'LAYOUT_ortho_4x4', 'LAYOUT') + replace_string(keymaps_path / 'default/keymap.c', 'LAYOUT_ortho_4x4', 'LAYOUT') cli.log.info(f'{{fg_green}}Created a new keyboard called {{fg_cyan}}{kb_name}{{fg_green}}.{{fg_reset}}') cli.log.info(f"Build Command: {{fg_yellow}}qmk compile -kb {kb_name} -km default{{fg_reset}}.") |