summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErovia <erovia@users.noreply.github.com>2019-10-13 20:23:11 +0200
committerskullydazed <skullydazed@users.noreply.github.com>2019-10-23 22:46:30 -0700
commita5a31a5fc0f14f4f66cf362ee85747be159e364d (patch)
tree6e9788f22fa7c8207bd217bae7a2b6e50450b7a5
parent4da9d2ef6f3f3a91738a209f8e692d7294ef70d5 (diff)
downloadqmk_firmware-a5a31a5fc0f14f4f66cf362ee85747be159e364d.tar.gz
qmk_firmware-a5a31a5fc0f14f4f66cf362ee85747be159e364d.zip
MILC: Use dashes instead of underscores for subcommands
The subcommand functions' name follows the Python convention of using snake case, but looks odd on the command line. Fix it by converting underscores to dashes, eg.: list_keyboards -> list-keyboards.
-rw-r--r--docs/cli.md4
-rw-r--r--lib/python/milc.py7
-rw-r--r--lib/python/qmk/tests/test_cli_commands.py2
3 files changed, 7 insertions, 6 deletions
diff --git a/docs/cli.md b/docs/cli.md
index d150ee917d..0d3703c8cf 100644
--- a/docs/cli.md
+++ b/docs/cli.md
@@ -125,14 +125,14 @@ This command examines your environment and alerts you to potential build or flas
qmk doctor
```
-## `qmk list_keyboards`
+## `qmk list-keyboards`
This command lists all the keyboards currently defined in `qmk_firmware`
**Usage**:
```
-qmk list_keyboards
+qmk list-keyboards
```
## `qmk new-keymap`
diff --git a/lib/python/milc.py b/lib/python/milc.py
index 1a29bb25c8..7b130bdea6 100644
--- a/lib/python/milc.py
+++ b/lib/python/milc.py
@@ -429,11 +429,12 @@ class MILC(object):
self.arg_only.append(arg_name)
del kwargs['arg_only']
+ name = handler.__name__.replace("_", "-")
if handler is self._entrypoint:
self.add_argument(*args, **kwargs)
- elif handler.__name__ in self.subcommands:
- self.subcommands[handler.__name__].add_argument(*args, **kwargs)
+ elif name in self.subcommands:
+ self.subcommands[name].add_argument(*args, **kwargs)
else:
raise RuntimeError('Decorated function is not entrypoint or subcommand!')
@@ -599,7 +600,7 @@ class MILC(object):
self.add_subparsers()
if not name:
- name = handler.__name__
+ name = handler.__name__.replace("_", "-")
self.acquire_lock()
kwargs['help'] = description
diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py
index c9d632517b..9a9dc4b958 100644
--- a/lib/python/qmk/tests/test_cli_commands.py
+++ b/lib/python/qmk/tests/test_cli_commands.py
@@ -40,7 +40,7 @@ def test_pyformat():
def test_list_keyboards():
- result = check_subcommand('list_keyboards')
+ result = check_subcommand('list-keyboards')
assert result.returncode == 0
# check to see if a known keyboard is returned
# this will fail if handwired/onekey/pytest is removed