keymap.py 919 B

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