1 """Create a keymap directory from a configurator export.
14 @cli.argument('filename', help='Configurator JSON export')
15 @cli.entrypoint('Compile a QMK Configurator export.')
17 """Compile a QMK Configurator export.
19 This command creates a new keymap from a configurator export, overwriting an existing keymap if one exists.
21 FIXME(skullydazed): add code to check and warn if the keymap already exists
24 if cli.args.filename == ('-'):
25 cli.log.error('Reading from STDIN is not (yet) supported.')
27 if not os.path.exists(qmk.path.normpath(cli.args.filename)):
28 cli.log.error('JSON file does not exist!')
31 # Parse the configurator json
32 with open(qmk.path.normpath(cli.args.filename), 'r') as fd:
33 user_keymap = json.load(fd)
36 keymap_path = qmk.path.keymap(user_keymap['keyboard'])
37 cli.log.info('Creating {fg_cyan}%s{style_reset_all} keymap in {fg_cyan}%s', user_keymap['keymap'], keymap_path)
38 qmk.keymap.write(user_keymap['keyboard'], user_keymap['keymap'], user_keymap['layout'], user_keymap['layers'])
39 cli.log.info('Wrote keymap to {fg_cyan}%s/%s/keymap.c', keymap_path, user_keymap['keymap'])
42 command = ['make', ':'.join((user_keymap['keyboard'], user_keymap['keymap']))]
43 cli.log.info('Compiling keymap with {fg_cyan}%s\n\n', ' '.join(command))
44 subprocess.run(command)