diff options
Diffstat (limited to 'lib/python/qmk/cli/list')
-rw-r--r-- | lib/python/qmk/cli/list/__init__.py | 1 | ||||
-rw-r--r-- | lib/python/qmk/cli/list/keymaps.py | 22 |
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/python/qmk/cli/list/__init__.py b/lib/python/qmk/cli/list/__init__.py index c36ba69548..d83cd20b5b 100644 --- a/lib/python/qmk/cli/list/__init__.py +++ b/lib/python/qmk/cli/list/__init__.py @@ -1 +1,2 @@ from . import keyboards +from . import keymaps diff --git a/lib/python/qmk/cli/list/keymaps.py b/lib/python/qmk/cli/list/keymaps.py new file mode 100644 index 0000000000..d199d29bc3 --- /dev/null +++ b/lib/python/qmk/cli/list/keymaps.py @@ -0,0 +1,22 @@ +"""List the keymaps for a specific keyboard +""" +from milc import cli +import qmk.keymap +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") +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?") |