429d41076025 — Antoine Perus 8 years ago
Use @cmdutil.command decorator to define command table.
1 files changed, 18 insertions(+), 13 deletions(-)

M src/b.py
M src/b.py +18 -13
@@ 39,7 39,10 @@ import os, errno, re, hashlib, sys, subp
 from datetime import date, datetime
 from operator import itemgetter
 from mercurial.i18n import _
-from mercurial import hg,commands
+from mercurial import hg, commands, cmdutil
+
+cmdtable = {}
+command = cmdutil.command(cmdtable)
 
 #
 # Version

          
@@ 597,6 600,20 @@ def _cat(ui,repo,file,todir,rev=None):
 #
 # Command line processing
 #
+@command("b|bug|bugs",
+         [
+          ('f', 'force', False, _('Force this exact username')),
+          ('e', 'edit', False, _('Launch details editor after running command')),
+          ('r', 'resolved', False, _('List resolved bugs')),
+          ('o', 'owner', '*', _('Specify an owner to list by')),
+          ('g', 'grep', '', _('Filter titles by STRING')),
+          ('a', 'alpha', False, _('Sort list alphabetically')),
+          ('c', 'chrono', False, _('Sort list chronologically')),
+          ('T', 'truncate', False, _('Truncate list output to fit window')),
+          ('', 'rev', '', _('Run a read-only command against a different revision'))
+         ],
+         "cmd [args]"
+        )
 def cmd(ui,repo,cmd = 'list',*args,**opts):
     """ Distributed Bug Tracker For Mercurial
     

          
@@ 821,18 838,6 @@ def cmd(ui,repo,cmd = 'list',*args,**opt
         ui.warn(_("'%s' is not a read-only command - cannot run against a past revision\n") % e.cmd)
 
     #open=True,owner='*',grep='',verbose=False,quiet=False):
-cmdtable = {"b|bug|bugs": (cmd,[
-                                ('f', 'force', False, _('Force this exact username')),
-                                ('e', 'edit', False, _('Launch details editor after running command')),
-                                ('r', 'resolved', False, _('List resolved bugs')),
-                                ('o', 'owner', '*', _('Specify an owner to list by')),
-                                ('g', 'grep', '', _('Filter titles by STRING')),
-                                ('a', 'alpha', False, _('Sort list alphabetically')),
-                                ('c', 'chrono', False, _('Sort list chronologically')),
-                                ('T', 'truncate', False, _('Truncate list output to fit window')),
-                                ('', 'rev', '', _('Run a read-only command against a different revision'))
-                           ]
-                           ,_("cmd [args]"))}
 
 #
 # Programmatic access to b