summaryrefslogtreecommitdiff
path: root/lib/python/qmk/cli
diff options
context:
space:
mode:
authorErovia <erovia@users.noreply.github.com>2019-10-08 21:50:21 +0200
committerDrashna Jael're <drashna@live.com>2020-03-26 00:42:11 -0700
commit4c3335b00bbcb4fa96056babcae6b10b4ab877a1 (patch)
treee57629841445b747dfa95cdb2e40325c1817cc7d /lib/python/qmk/cli
parent2b0c1a766176eaddb2af37bb24b1f39003d6afb7 (diff)
CLI: add support for list_keymaps
List all the available keymaps for a given keyboard Add bs4 to requirements.txt UnicodeDammit is needed from bs4 for reading files. Major update to work better with revisions Find the community keymaps supported by each revision. Get all buildable keymaps for each revision The command now return all keymaps that's buildable for a keyboard/revision. If the base directory of a keyboard does not contain a 'rules.mk' file, nothing is returned. If the base directory contains a 'keymaps' directory, those keycaps will be returned for every revision. Fix help message. Try to figure out revision, drop -rv/--revision argument Fix output format Another major refactoring, add documentation Move all useful functions to the qmk module and use the cli subcommand as a wrapper around it. Add both inline comments and documentation. Add test for list_keymaps Fix regex for parsing rules.mk files I don't know why it couldn't put it together before... ¯\_(ツ)_/¯ Drop bs4 dependency, update docs, minor improvements Return only the unique keymaps Fix merging community and base keymaps Major rework, no regex/globbing, more walking Instead of using regexes and globbing to find the rules.mk and keymap.c files, walk the directory tree to find them. Also, do away with the concept of revision. Fix commandline parsing and flake8 findings, rebase Fixed commandline and config parsing. Thx @xplusplus. Rebased on master and fixed merge conflicts. Code cleanup, use pathlib, use pytest keyboard Clean up checks and logics that are unnecessary due to MILC updates. Use pathlib instead of os.path for readability. Use the 'pytest' keyboard for the tests. Add community layout for 'handwired/onekey/pytest' so we can test community layouts. Pathlib-ify qmk.keymap.list_keymaps() fix list_keymaps for python 3.5
Diffstat (limited to 'lib/python/qmk/cli')
-rw-r--r--lib/python/qmk/cli/list/__init__.py1
-rw-r--r--lib/python/qmk/cli/list/keymaps.py22
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?")