f81b0e35a6
* Use pathlib everywhere we can * Improvements based on @erovia's feedback * rework qmk compile and qmk flash to use pathlib * style * Remove the subcommand_name argument from find_keyboard_keymap() * add experimental decorators * Create decorators for finding keyboard and keymap based on current directory. Decorators were inspired by @Erovia's brilliant work on the proof of concept.
26 lines
983 B
Python
26 lines
983 B
Python
"""List the keymaps for a specific keyboard
|
|
"""
|
|
from milc import cli
|
|
|
|
import qmk.keymap
|
|
from qmk.decorators import automagic_keyboard
|
|
from qmk.errors import NoSuchKeyboardError
|
|
|
|
|
|
@cli.argument("-kb", "--keyboard", help="Specify keyboard name. Example: 1upkeyboards/1up60hse")
|
|
@cli.subcommand("List the keymaps for a specific keyboard")
|
|
@automagic_keyboard
|
|
def list_keymaps(cli):
|
|
"""List the keymaps for a specific keyboard
|
|
"""
|
|
try:
|
|
for name in qmk.keymap.list_keymaps(cli.config.list_keymaps.keyboard):
|
|
# We echo instead of cli.log.info to allow easier piping of this output
|
|
cli.echo('%s', name)
|
|
except NoSuchKeyboardError as e:
|
|
cli.echo("{fg_red}%s: %s", cli.config.list_keymaps.keyboard, e.message)
|
|
except (FileNotFoundError, PermissionError) as e:
|
|
cli.echo("{fg_red}%s: %s", cli.config.list_keymaps.keyboard, e)
|
|
except TypeError:
|
|
cli.echo("{fg_red}Something went wrong. Did you specify a keyboard?")
|