1
0
Fork 0

Add cli command to import keyboard|keymap|kbfirmware (#16668)

This commit is contained in:
Joel Challis 2022-07-02 12:50:09 +01:00 committed by GitHub
parent 9dc7b9d40c
commit 59e28b8958
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 290 additions and 0 deletions

View file

View file

@ -0,0 +1,25 @@
from milc import cli
from qmk.importers import import_kbfirmware as _import_kbfirmware
from qmk.path import FileType
from qmk.json_schema import json_load
@cli.argument('filename', type=FileType('r'), nargs='+', arg_only=True, help='file')
@cli.subcommand('Import kbfirmware json export')
def import_kbfirmware(cli):
filename = cli.args.filename[0]
data = json_load(filename)
cli.log.info(f'{{style_bright}}Importing {filename.name}.{{style_normal}}')
cli.echo('')
cli.log.warn("Support here is basic - Consider using 'qmk new-keyboard' instead")
kb_name = _import_kbfirmware(data)
cli.log.info(f'{{fg_green}}Imported a new keyboard named {{fg_cyan}}{kb_name}{{fg_green}}.{{fg_reset}}')
cli.log.info(f'To start working on things, `cd` into {{fg_cyan}}keyboards/{kb_name}{{fg_reset}},')
cli.log.info('or open the directory in your preferred text editor.')
cli.log.info(f"And build with {{fg_yellow}}qmk compile -kb {kb_name} -km default{{fg_reset}}.")

View file

@ -0,0 +1,23 @@
from milc import cli
from qmk.importers import import_keyboard as _import_keyboard
from qmk.path import FileType
from qmk.json_schema import json_load
@cli.argument('filename', type=FileType('r'), nargs='+', arg_only=True, help='file')
@cli.subcommand('Import data-driven keyboard')
def import_keyboard(cli):
filename = cli.args.filename[0]
data = json_load(filename)
cli.log.info(f'{{style_bright}}Importing {filename.name}.{{style_normal}}')
cli.echo('')
kb_name = _import_keyboard(data)
cli.log.info(f'{{fg_green}}Imported a new keyboard named {{fg_cyan}}{kb_name}{{fg_green}}.{{fg_reset}}')
cli.log.info(f'To start working on things, `cd` into {{fg_cyan}}keyboards/{kb_name}{{fg_reset}},')
cli.log.info('or open the directory in your preferred text editor.')
cli.log.info(f"And build with {{fg_yellow}}qmk compile -kb {kb_name} -km default{{fg_reset}}.")

View file

@ -0,0 +1,23 @@
from milc import cli
from qmk.importers import import_keymap as _import_keymap
from qmk.path import FileType
from qmk.json_schema import json_load
@cli.argument('filename', type=FileType('r'), nargs='+', arg_only=True, help='file')
@cli.subcommand('Import data-driven keymap')
def import_keymap(cli):
filename = cli.args.filename[0]
data = json_load(filename)
cli.log.info(f'{{style_bright}}Importing {filename.name}.{{style_normal}}')
cli.echo('')
kb_name, km_name = _import_keymap(data)
cli.log.info(f'{{fg_green}}Imported a new keymap named {{fg_cyan}}{km_name}{{fg_green}}.{{fg_reset}}')
cli.log.info(f'To start working on things, `cd` into {{fg_cyan}}keyboards/{kb_name}/keymaps/{km_name}{{fg_reset}},')
cli.log.info('or open the directory in your preferred text editor.')
cli.log.info(f"And build with {{fg_yellow}}qmk compile -kb {kb_name} -km {km_name}{{fg_reset}}.")