Fix :help commands
authorJack Miller <jack@codezen.org>
Thu, 25 Jun 2015 17:14:06 +0000 (12:14 -0500)
committerJack Miller <jack@codezen.org>
Thu, 25 Jun 2015 17:14:06 +0000 (12:14 -0500)
canto_curses/command.py
canto_curses/guibase.py

index 72196cd..44022f5 100644 (file)
@@ -62,13 +62,15 @@ def register_commands(obj, cmds, group="hidden"):
         func, args, help_text = cmds[name]
         register_command(obj, name, func, args, help_text, group)
 
-def commands():
+def commands(g=None):
     c = []
 
     for ck in cmds.keys():
         group = cmds[ck][-1].group
         if group == "hidden":
             continue
+        if g and g != group:
+            continue
 
         for ak in aliases.keys():
             if aliases[ak][-1].longform == ck:
@@ -78,6 +80,14 @@ def commands():
                 c.append(ck)
     return c
 
+def groups():
+    g = []
+    for ck in cmds.keys():
+        grp = cmds[ck][-1].group
+        if grp != "hidden" and grp not in g:
+            g.append(grp)
+    return g
+
 def command_help(command, detailed=False):
     lookup = shlex.split(command)
     working_cmd = _get_max_sig(lookup)[-1]
index 841558a..57c7348 100644 (file)
@@ -10,7 +10,7 @@ from canto_next.hooks import on_hook
 from canto_next.plugins import Plugin
 from canto_next.remote import assign_to_dict, access_dict
 
-from .command import CommandHandler, register_commands, register_arg_types, unregister_all, _string, register_aliases, commands, command_help
+from .command import CommandHandler, register_commands, register_arg_types, unregister_all, _string, register_aliases, commands, command_help, groups
 from .tagcore import tag_updater
 from .theme import prep_for_display
 from .config import needs_eval, config
@@ -281,11 +281,10 @@ class GuiBase(CommandHandler):
                         log.info("%s %s" % (bindeff, cmd))
 
         elif cmd == 'commands':
-            gc = commands()
-            for group in sorted(gc.keys()):
+            for group in sorted(groups()):
                 log.info("%B" + group + "%b\n")
                 tmp = {}
-                for c in gc[group]:
+                for c in commands(group):
                     tmp[c] = command_help(c)
 
                 maxcmdl = max([ len(x) for x in tmp ])