mirror of
https://github.com/firewalkwithm3/qmk_firmware.git
synced 2024-11-22 11:30:30 +08:00
qmk compile
/qmk flash
- Validate keymap argument (#19530)
This commit is contained in:
parent
baecc69da5
commit
a1f253cbef
|
@ -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))
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue