Sfoglia il codice sorgente

improve help command

Eren Yilmaz 6 anni fa
parent
commit
64ea3510b7
1 ha cambiato i file con 12 aggiunte e 9 eliminazioni
  1. 12 9
      client_controller.py

+ 12 - 9
client_controller.py

@@ -127,22 +127,25 @@ def change_password(password=None, retype_password=None):
 # noinspection PyShadowingBuiltins
 def help():
     print('Allowed commands:')
+    command_table = []
     for cmd in allowed_commands:
         this_module = sys.modules[__name__]
         method = getattr(this_module, cmd)
         params = signature(method).parameters
         num_args = len(params)
-        if num_args > 0:
-            print('`' + cmd + '`', 'takes the following', num_args, 'arguments:')
-            for p in params:
-                print(' -', p)
-        else:
-            print('`' + cmd + '`', 'takes no arguments')
-        print()
-
+        command_table.append([cmd] + [p for p in params])
+
+    print(_my_tabulate(command_table,tablefmt='pipe',headers=['command',
+                                                              'parameter 1',
+                                                              'parameter 2',
+                                                              'parameter 3',
+                                                              'parameter 4',
+                                                              'parameter 5',
+                                                              ]))
     print('NOTE:')
+    print('  All parameters for all commands are optional!')
     print('  Commands can be combined in one line with ; between them.')
-    print('  All arguments for all commands are optional!')
+    print('  Parameters are separated with any whitespace.')
 
 
 def _my_tabulate(data, **params):