2019-10-08 19:50:21 +00:00
|
|
|
"""List the keymaps for a specific keyboard
|
|
|
|
"""
|
|
|
|
from milc import cli
|
2019-10-13 17:07:22 +00:00
|
|
|
import qmk.keymap
|
|
|
|
from qmk.errors import NoSuchKeyboardError
|
2019-10-09 08:14:53 +00:00
|
|
|
|
2020-01-07 20:54:21 +00:00
|
|
|
|
2019-10-09 18:53:18 +00:00
|
|
|
@cli.argument("-kb", "--keyboard", help="Specify keyboard name. Example: 1upkeyboards/1up60hse")
|
2019-10-08 19:50:21 +00:00
|
|
|
@cli.subcommand("List the keymaps for a specific keyboard")
|
|
|
|
def list_keymaps(cli):
|
|
|
|
"""List the keymaps for a specific keyboard
|
|
|
|
"""
|
|
|
|
# ask for user input if keyboard was not provided in the command line
|
2020-01-07 20:54:21 +00:00
|
|
|
if cli.args.keyboard:
|
|
|
|
cli.config.list_keymaps.keyboard = cli.args.keyboard
|
|
|
|
elif not cli.config.list_keymaps.keyboard:
|
2019-10-24 18:33:58 +00:00
|
|
|
cli.config.list_keymaps.keyboard = input("Keyboard Name: ")
|
2019-10-08 19:50:21 +00:00
|
|
|
|
2019-10-13 17:07:22 +00:00
|
|
|
try:
|
2019-10-24 18:33:58 +00:00
|
|
|
for name in qmk.keymap.list_keymaps(cli.config.list_keymaps.keyboard):
|
2019-10-13 17:07:22 +00:00
|
|
|
# We echo instead of cli.log.info to allow easier piping of this output
|
2019-10-24 18:33:58 +00:00
|
|
|
cli.echo('%s:%s', cli.config.list_keymaps.keyboard, name)
|
2019-10-13 17:07:22 +00:00
|
|
|
except NoSuchKeyboardError as e:
|
2019-10-24 18:33:58 +00:00
|
|
|
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)
|