Compare commits

..

2 Commits

Author SHA1 Message Date
skullY
00fb1bd1f0 Make generating keymap.c from JSON more reliable 2019-11-12 20:37:28 -08:00
skullY
79edb7c594 Small CLI cleanups
* yapf changes
* Fix the cformat test
* Make the normpath test work when run from /
* `qmk config`: Mark `--read-only` as arg_only
2019-11-12 18:41:38 -08:00
8 changed files with 9 additions and 9 deletions

View File

@@ -22,6 +22,5 @@ else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_1)/keymap.json)","")
endif
# Generate the keymap.c
ifneq ("$(KEYMAP_JSON)","")
_ = $(shell test -e $(KEYMAP_C) || bin/qmk json-keymap $(KEYMAP_JSON) -o $(KEYMAP_C))
endif
$(KEYBOARD_OUTPUT)/src/keymap.c:
bin/qmk json-keymap --quiet --output $(KEYMAP_C) $(KEYMAP_JSON)

View File

@@ -12,7 +12,7 @@ def print_config(section, key):
cli.echo('%s.%s{fg_cyan}={fg_reset}%s', section, key, cli.config[section][key])
@cli.argument('-ro', '--read-only', action='store_true', help='Operate in read-only mode.')
@cli.argument('-ro', '--read-only', arg_only=True, action='store_true', help='Operate in read-only mode.')
@cli.argument('configs', nargs='*', arg_only=True, help='Configuration options to read or write.')
@cli.subcommand("Read and write configuration settings.")
def config(cli):

View File

@@ -10,6 +10,7 @@ import qmk.keymap
@cli.argument('-o', '--output', arg_only=True, help='File to write to')
@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages")
@cli.argument('filename', arg_only=True, help='Configurator JSON file')
@cli.subcommand('Creates a keymap.c from a QMK Configurator export.')
def json_keymap(cli):
@@ -48,7 +49,8 @@ def json_keymap(cli):
with open(output_file, 'w') as keymap_fd:
keymap_fd.write(keymap_c)
cli.log.info('Wrote keymap to %s.', cli.args.output)
if not cli.args.quiet:
cli.log.info('Wrote keymap to %s.', cli.args.output)
else:
print(keymap_c)

View File

@@ -6,6 +6,7 @@ import glob
from milc import cli
@cli.subcommand("List the keyboards currently defined within QMK")
def list_keyboards(cli):
"""List the keyboards currently defined within QMK

View File

@@ -1,6 +1,5 @@
class NoSuchKeyboardError(Exception):
"""Raised when we can't find a keyboard/keymap directory.
"""
def __init__(self, message):
self.message = message

View File

@@ -3,7 +3,6 @@ class AttrDict(dict):
This should only be used to mock objects for unit testing. Please do not use this outside of qmk.tests.
"""
def __init__(self, *args, **kwargs):
super(AttrDict, self).__init__(*args, **kwargs)
self.__dict__ = self

View File

@@ -7,7 +7,7 @@ def check_subcommand(command, *args):
def test_cformat():
assert check_subcommand('cformat', 'tmk_core/common/backlight.c').returncode == 0
assert check_subcommand('cformat', 'tmk_core/common/keyboard.c').returncode == 0
def test_compile():

View File

@@ -10,4 +10,4 @@ def test_keymap_onekey_pytest():
def test_normpath():
path = qmk.path.normpath('lib/python')
assert path == os.environ['ORIG_CWD'] + '/lib/python'
assert path == os.path.join(os.environ['ORIG_CWD'], 'lib/python')