summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/python/qmk/cli/compile.py17
-rw-r--r--lib/python/qmk/cli/flash.py17
2 files changed, 32 insertions, 2 deletions
diff --git a/lib/python/qmk/cli/compile.py b/lib/python/qmk/cli/compile.py
index 9e7629906f..f43e5f32de 100755
--- a/lib/python/qmk/cli/compile.py
+++ b/lib/python/qmk/cli/compile.py
@@ -10,7 +10,17 @@ import qmk.path
from qmk.decorators import automagic_keyboard, automagic_keymap
from qmk.commands import compile_configurator_json, create_make_command, parse_configurator_json, build_environment
from qmk.keyboard import keyboard_completer, keyboard_folder
-from qmk.keymap import keymap_completer
+from qmk.keymap import keymap_completer, locate_keymap
+
+
+def _is_keymap_target(keyboard, keymap):
+ if keymap == 'all':
+ return True
+
+ if locate_keymap(keyboard, keymap):
+ return True
+
+ return False
@cli.argument('filename', nargs='?', arg_only=True, type=qmk.path.FileType('r'), completer=FilesCompleter('.json'), help='The configurator export to compile')
@@ -43,6 +53,11 @@ def compile(cli):
elif cli.config.compile.keyboard and cli.config.compile.keymap:
# Generate the make command for a specific keyboard/keymap.
+ if not _is_keymap_target(cli.config.compile.keyboard, cli.config.compile.keymap):
+ cli.log.error('Invalid keymap argument.')
+ cli.print_help()
+ return False
+
if cli.args.clean:
commands.append(create_make_command(cli.config.compile.keyboard, cli.config.compile.keymap, 'clean', **envs))
commands.append(create_make_command(cli.config.compile.keyboard, cli.config.compile.keymap, parallel=cli.config.compile.parallel, **envs))
diff --git a/lib/python/qmk/cli/flash.py b/lib/python/qmk/cli/flash.py
index 52defb5f0d..8724f26889 100644
--- a/lib/python/qmk/cli/flash.py
+++ b/lib/python/qmk/cli/flash.py
@@ -11,10 +11,20 @@ import qmk.path
from qmk.decorators import automagic_keyboard, automagic_keymap
from qmk.commands import compile_configurator_json, create_make_command, parse_configurator_json, build_environment
from qmk.keyboard import keyboard_completer, keyboard_folder
-from qmk.keymap import keymap_completer
+from qmk.keymap import keymap_completer, locate_keymap
from qmk.flashers import flasher
+def _is_keymap_target(keyboard, keymap):
+ if keymap == 'all':
+ return True
+
+ if locate_keymap(keyboard, keymap):
+ return True
+
+ return False
+
+
def _list_bootloaders():
"""Prints the available bootloaders listed in docs.qmk.fm.
"""
@@ -98,6 +108,11 @@ def flash(cli):
elif cli.config.flash.keyboard and cli.config.flash.keymap:
# Generate the make command for a specific keyboard/keymap.
+ if not _is_keymap_target(cli.config.flash.keyboard, cli.config.flash.keymap):
+ cli.log.error('Invalid keymap argument.')
+ cli.print_help()
+ return False
+
if cli.args.clean:
commands.append(create_make_command(cli.config.flash.keyboard, cli.config.flash.keymap, 'clean', **envs))
commands.append(create_make_command(cli.config.flash.keyboard, cli.config.flash.keymap, cli.args.bootloader, parallel=cli.config.flash.parallel, **envs))