فهرست منبع

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.
Erovia 6 سال پیش
والد
کامیت
a5a31a5fc0
3فایلهای تغییر یافته به همراه7 افزوده شده و 6 حذف شده
  1. 2 2
      docs/cli.md
  2. 4 3
      lib/python/milc.py
  3. 1 1
      lib/python/qmk/tests/test_cli_commands.py

+ 2 - 2
docs/cli.md

@@ -125,14 +125,14 @@ This command examines your environment and alerts you to potential build or flas
 qmk doctor
 qmk doctor
 ```
 ```
 
 
-## `qmk list_keyboards`
+## `qmk list-keyboards`
 
 
 This command lists all the keyboards currently defined in `qmk_firmware`
 This command lists all the keyboards currently defined in `qmk_firmware`
 
 
 **Usage**:
 **Usage**:
 
 
 ```
 ```
-qmk list_keyboards
+qmk list-keyboards
 ```
 ```
 
 
 ## `qmk new-keymap`
 ## `qmk new-keymap`

+ 4 - 3
lib/python/milc.py

@@ -429,11 +429,12 @@ class MILC(object):
                 self.arg_only.append(arg_name)
                 self.arg_only.append(arg_name)
                 del kwargs['arg_only']
                 del kwargs['arg_only']
 
 
+            name = handler.__name__.replace("_", "-")
             if handler is self._entrypoint:
             if handler is self._entrypoint:
                 self.add_argument(*args, **kwargs)
                 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:
             else:
                 raise RuntimeError('Decorated function is not entrypoint or subcommand!')
                 raise RuntimeError('Decorated function is not entrypoint or subcommand!')
@@ -599,7 +600,7 @@ class MILC(object):
             self.add_subparsers()
             self.add_subparsers()
 
 
         if not name:
         if not name:
-            name = handler.__name__
+            name = handler.__name__.replace("_", "-")
 
 
         self.acquire_lock()
         self.acquire_lock()
         kwargs['help'] = description
         kwargs['help'] = description

+ 1 - 1
lib/python/qmk/tests/test_cli_commands.py

@@ -40,7 +40,7 @@ def test_pyformat():
 
 
 
 
 def test_list_keyboards():
 def test_list_keyboards():
-    result = check_subcommand('list_keyboards')
+    result = check_subcommand('list-keyboards')
     assert result.returncode == 0
     assert result.returncode == 0
     # check to see if a known keyboard is returned
     # check to see if a known keyboard is returned
     # this will fail if handwired/onekey/pytest is removed
     # this will fail if handwired/onekey/pytest is removed