diff mercurial/commands.py @ 14286:005a540e9aee

help: add -c/--command flag to only show command help (issue2799)
author Martin Geisler <mg@aragost.com>
date Tue, 10 May 2011 14:42:53 +0200
parents aa64a87b493d
children d68ddccf276b
line wrap: on
line diff
--- a/mercurial/commands.py	Tue May 10 13:19:05 2011 +0200
+++ b/mercurial/commands.py	Tue May 10 14:42:53 2011 +0200
@@ -2293,6 +2293,12 @@
 
         ui.write("%s\n\n" % header)
         ui.write("%s\n" % minirst.format(doc, textwidth, indent=4))
+        try:
+            cmdutil.findcmd(name, table)
+            ui.write(_('\nuse "hg help -c %s" to see help for '
+                       'the %s command\n') % (name, name))
+        except error.UnknownCommand:
+            pass
 
     def helpext(name):
         try:
@@ -2346,6 +2352,8 @@
             queries = (helpextcmd,)
         elif opts.get('extension'):
             queries = (helpext,)
+        elif opts.get('command'):
+            queries = (helpcmd,)
         else:
             queries = (helptopic, helpcmd, helpext, helpextcmd)
         for f in queries:
@@ -4720,8 +4728,9 @@
          ] + templateopts,
          _('[-ac] [-r STARTREV] [REV]...')),
     "help": (help_,
-        [('e', 'extension', None, _('show only help for extensions'))],
-        _('[-e] [TOPIC]')),
+        [('e', 'extension', None, _('show only help for extensions')),
+         ('c', 'command', None, _('show only help for commands'))],
+        _('[-ec] [TOPIC]')),
     "identify|id":
         (identify,
          [('r', 'rev', '',