]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
MILC: Use dashes instead of underscores for subcommands
authorErovia <erovia@users.noreply.github.com>
Sun, 13 Oct 2019 18:23:11 +0000 (20:23 +0200)
committerskullydazed <skullydazed@users.noreply.github.com>
Thu, 24 Oct 2019 05:46:30 +0000 (22:46 -0700)
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.

docs/cli.md
lib/python/milc.py
lib/python/qmk/tests/test_cli_commands.py

index d150ee917de50ca7bd459226fcdb33d23546cc33..0d3703c8cf0f0d3e902dac6ff554ef0e4f8508ff 100644 (file)
@@ -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`
index 1a29bb25c8643394951782c246aea025f27c8cbd..7b130bdea606e048923bab42524d2c40b53fde02 100644 (file)
@@ -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
index c9d632517bdc676997f852897b3dd4770b17b68e..9a9dc4b958af1831a5bce10df56c9174752c127f 100644 (file)
@@ -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