summaryrefslogtreecommitdiff
path: root/lib/python/qmk/cli/import/keyboard.py
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2022-07-02 12:50:09 +0100
committerGitHub <noreply@github.com>2022-07-02 21:50:09 +1000
commit59e28b8958db4940f026c4bbd81dee7b9b5e49b0 (patch)
treec9c8ba26fdef7a47e640ee34d22fd1199e0c669e /lib/python/qmk/cli/import/keyboard.py
parent9dc7b9d40cfa199875cdc9e2e05b15d3f463b415 (diff)
Add cli command to import keyboard|keymap|kbfirmware (#16668)
Diffstat (limited to 'lib/python/qmk/cli/import/keyboard.py')
-rw-r--r--lib/python/qmk/cli/import/keyboard.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/python/qmk/cli/import/keyboard.py b/lib/python/qmk/cli/import/keyboard.py
new file mode 100644
index 0000000000..3a5ed37dee
--- /dev/null
+++ b/lib/python/qmk/cli/import/keyboard.py
@@ -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}}.")