summaryrefslogtreecommitdiffstats
path: root/lib/python/qmk/cli/list
diff options
context:
space:
mode:
authorZach White <skullydazed@users.noreply.github.com>2020-05-26 13:05:41 -0700
committerGitHub <noreply@github.com>2020-05-26 13:05:41 -0700
commit751316c34465ea77e066c3052729b207f3d62e0c (patch)
treecb99656b93c156757e2fd7c84fe716f9c300ca89 /lib/python/qmk/cli/list
parent5d3bf8a050f3c0beb1f91147dc1ab54de36cbb05 (diff)
[CLI] Add a subcommand for getting information about a keyboard (#8666)
You can now use `qmk info` to get information about keyboards and keymaps. Co-authored-by: Erovia <Erovia@users.noreply.github.com>
Diffstat (limited to 'lib/python/qmk/cli/list')
-rw-r--r--lib/python/qmk/cli/list/keymaps.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/python/qmk/cli/list/keymaps.py b/lib/python/qmk/cli/list/keymaps.py
index cec9ca0224..b18289eb35 100644
--- a/lib/python/qmk/cli/list/keymaps.py
+++ b/lib/python/qmk/cli/list/keymaps.py
@@ -4,7 +4,7 @@ from milc import cli
import qmk.keymap
from qmk.decorators import automagic_keyboard
-from qmk.errors import NoSuchKeyboardError
+from qmk.path import is_keyboard
@cli.argument("-kb", "--keyboard", help="Specify keyboard name. Example: 1upkeyboards/1up60hse")
@@ -13,13 +13,9 @@ from qmk.errors import NoSuchKeyboardError
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?")
+ if not is_keyboard(cli.config.list_keymaps.keyboard):
+ cli.log.error('Keyboard %s does not exist!', cli.config.list_keymaps.keyboard)
+ exit(1)
+
+ for name in qmk.keymap.list_keymaps(cli.config.list_keymaps.keyboard):
+ print(name)