mirror of
https://github.com/qmk/qmk_firmware.git
synced 2024-11-22 03:19:24 +00:00
qmk new-keyboard
- detach community layout when selecting "none of the above" (#20405)
This commit is contained in:
parent
aea414fd82
commit
6720e9c58c
@ -74,6 +74,10 @@ def replace_placeholders(src, dest, tokens):
|
|||||||
dest.write_text(content)
|
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):
|
def augment_community_info(src, dest):
|
||||||
"""Splice in any additional data into info.json
|
"""Splice in any additional data into info.json
|
||||||
"""
|
"""
|
||||||
@ -218,6 +222,11 @@ def new_keyboard(cli):
|
|||||||
else:
|
else:
|
||||||
bootloader = select_default_bootloader(mcu)
|
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
|
tokens = { # Comment here is to force multiline formatting
|
||||||
'YEAR': str(date.today().year),
|
'YEAR': str(date.today().year),
|
||||||
'KEYBOARD': kb_name,
|
'KEYBOARD': kb_name,
|
||||||
@ -233,10 +242,6 @@ def new_keyboard(cli):
|
|||||||
for key, value in tokens.items():
|
for key, value in tokens.items():
|
||||||
cli.echo(f" {key.ljust(10)}: {value}")
|
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
|
# begin with making the deepest folder in the tree
|
||||||
keymaps_path = keyboard(kb_name) / 'keymaps/'
|
keymaps_path = keyboard(kb_name) / 'keymaps/'
|
||||||
keymaps_path.mkdir(parents=True)
|
keymaps_path.mkdir(parents=True)
|
||||||
@ -253,6 +258,11 @@ def new_keyboard(cli):
|
|||||||
community_info = Path(COMMUNITY / f'{default_layout}/info.json')
|
community_info = Path(COMMUNITY / f'{default_layout}/info.json')
|
||||||
augment_community_info(community_info, keyboard(kb_name) / 'keyboard.json')
|
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'{{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}}.")
|
cli.log.info(f"Build Command: {{fg_yellow}}qmk compile -kb {kb_name} -km default{{fg_reset}}.")
|
||||||
cli.log.info(f'Project Location: {{fg_cyan}}{QMK_FIRMWARE}/{keyboard(kb_name)}{{fg_reset}},')
|
cli.log.info(f'Project Location: {{fg_cyan}}{QMK_FIRMWARE}/{keyboard(kb_name)}{{fg_reset}},')
|
||||||
|
Loading…
Reference in New Issue
Block a user