Commits

Olemis Lang committed 36b49ca

BH Multiproduct #475 : List commands in product scope with short help

Comments (0)

Files changed (2)

-t475/t475_r1460340_product_trac_admin_crud.diff
+t475/t475_r1480224_product_trac_admin_help.diff
 #t430/t430_r1457691_product_plugin_admin.diff
 #t430/t430_r1457691_product_admin_whitelist.diff
 #t430/t430_r1458841_product_admin_defaults.diff
 #t475/t475_r1457691_product_trac_admin.diff
+#t475/t475_r1460340_product_trac_admin_crud.diff

t475/t475_r1480224_product_trac_admin_help.diff

+# HG changeset patch
+# Parent f7782e6480e5a69e253bee67f5d27db6b320758a
+BH Multiproduct #475 : trac-admin product admin <prefix> help
+
+diff -r f7782e6480e5 bloodhound_multiproduct/multiproduct/product_admin.py
+--- a/bloodhound_multiproduct/multiproduct/product_admin.py	Wed May 08 11:14:34 2013 +0000
++++ b/bloodhound_multiproduct/multiproduct/product_admin.py	Thu May 09 13:40:53 2013 -0500
+@@ -20,6 +20,7 @@
+ 
+ from trac.admin.api import IAdminCommandProvider, AdminCommandError,\
+     AdminCommandManager
++from trac.admin.console import TracAdmin, TRAC_VERSION
+ from trac.admin.web_ui import AdminModule
+ from trac.core import *
+ from trac.config import *
+@@ -27,8 +28,8 @@
+ from trac.resource import ResourceNotFound
+ from trac.ticket.admin import TicketAdminPanel, _save_config
+ from trac.util import lazy
+-from trac.util.text import print_table, to_unicode
+-from trac.util.translation import _, N_, gettext
++from trac.util.text import print_table, to_unicode, printerr, printout
++from trac.util.translation import _, N_, gettext, ngettext
+ from trac.web.api import HTTPNotFound, IRequestFilter, IRequestHandler
+ from trac.web.chrome import Chrome, add_notice, add_warning
+ 
+@@ -296,11 +297,34 @@
+ 
+     def _do_product_admin(self, prefix, *args):
+         mgr = self.product_admincmd_mgr(prefix)
+-        if args and args[0] in ('deploy', 'help', 'hotcopy', 'initenv', 
+-                                'upgrade'):
++        if args and args[0] in ('deploy', 'hotcopy', 'initenv', 'upgrade'):
+             raise AdminCommandError('%s command not supported for products' %
+                                     (args[0],))
+-        mgr.execute_command(*args)
++        if args[0] == 'help':
++            help_args = args[1:]
++            if help_args:
++                doc = mgr.get_command_help(help_args)
++                if doc:
++                    TracAdmin.print_doc(doc)
++                else:
++                    printerr(_("No documentation found for '%(cmd)s'."
++                               " Use 'help' to see the list of commands.",
++                               cmd=' '.join(help_args)))
++                    cmds = mgr.get_similar_commands(help_args[0])
++                    if cmds:
++                        printout('')
++                        printout(ngettext("Did you mean this?",
++                                          "Did you mean one of these?",
++                                          len(cmds)))
++                        for cmd in cmds:
++                            printout('    ' + cmd)
++            else:
++                printout(_("trac-admin - The Trac Administration Console "
++                           "%(version)s", version=TRAC_VERSION))
++                env = mgr.env
++                TracAdmin.print_doc(TracAdmin.all_docs(env), short=True)
++        else:
++            mgr.execute_command(*args)
+ 
+     # IRequestFilter methods
+     def pre_process_request(self, req, handler):