summaryrefslogtreecommitdiff
path: root/lib/python/qmk/cli/flash.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python/qmk/cli/flash.py')
-rw-r--r--lib/python/qmk/cli/flash.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/python/qmk/cli/flash.py b/lib/python/qmk/cli/flash.py
index a876290035..1b2932a5b2 100644
--- a/lib/python/qmk/cli/flash.py
+++ b/lib/python/qmk/cli/flash.py
@@ -3,13 +3,15 @@
You can compile a keymap already in the repo or using a QMK Configurator export.
A bootloader must be specified.
"""
-from argparse import FileType
+from subprocess import DEVNULL
+from argcomplete.completers import FilesCompleter
from milc import cli
import qmk.path
from qmk.decorators import automagic_keyboard, automagic_keymap
from qmk.commands import compile_configurator_json, create_make_command, parse_configurator_json
+from qmk.keyboard import keyboard_completer, keyboard_folder
def print_bootloader_help():
@@ -30,11 +32,11 @@ def print_bootloader_help():
cli.echo('For more info, visit https://docs.qmk.fm/#/flashing')
-@cli.argument('filename', nargs='?', arg_only=True, type=FileType('r'), help='The configurator export JSON to compile.')
+@cli.argument('filename', nargs='?', arg_only=True, type=qmk.path.FileType('r'), completer=FilesCompleter('.json'), help='The configurator export JSON to compile.')
@cli.argument('-b', '--bootloaders', action='store_true', help='List the available bootloaders.')
@cli.argument('-bl', '--bootloader', default='flash', help='The flash command, corresponding to qmk\'s make options of bootloaders.')
@cli.argument('-km', '--keymap', help='The keymap to build a firmware for. Use this if you dont have a configurator file. Ignored when a configurator file is supplied.')
-@cli.argument('-kb', '--keyboard', help='The keyboard to build a firmware for. Use this if you dont have a configurator file. Ignored when a configurator file is supplied.')
+@cli.argument('-kb', '--keyboard', type=keyboard_folder, completer=keyboard_completer, help='The keyboard to build a firmware for. Use this if you dont have a configurator file. Ignored when a configurator file is supplied.')
@cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Don't actually build, just show the make command to be run.")
@cli.argument('-j', '--parallel', type=int, default=1, help="Set the number of parallel make jobs to run.")
@cli.argument('-e', '--env', arg_only=True, action='append', default=[], help="Set a variable to be passed to make. May be passed multiple times.")
@@ -54,7 +56,7 @@ def flash(cli):
"""
if cli.args.clean and not cli.args.filename and not cli.args.dry_run:
command = create_make_command(cli.config.flash.keyboard, cli.config.flash.keymap, 'clean')
- cli.run(command, capture_output=False)
+ cli.run(command, capture_output=False, stdin=DEVNULL)
# Build the environment vars
envs = {}
@@ -97,7 +99,7 @@ def flash(cli):
cli.log.info('Compiling keymap with {fg_cyan}%s', ' '.join(command))
if not cli.args.dry_run:
cli.echo('\n')
- compile = cli.run(command, capture_output=False, text=True)
+ compile = cli.run(command, capture_output=False, stdin=DEVNULL)
return compile.returncode
else: