[PATCH 3 of 4] help: add --keyword (-k) for searching help
Augie Fackler
raf at durin42.com
Sun May 13 07:29:08 CDT 2012
# HG changeset patch
# User Augie Fackler <raf at durin42.com>
# Date 1336906991 18000
# Node ID c88d58df58f87468a597a5c36f3563616e5e79b4
# Parent aa8d4ae5cb5c77c49b788e782c2c8aafd202659c
help: add --keyword (-k) for searching help
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3054,7 +3054,9 @@
@command('help',
[('e', 'extension', None, _('show only help for extensions')),
- ('c', 'command', None, _('show only help for commands'))],
+ ('c', 'command', None, _('show only help for commands')),
+ ('k', 'keyword', '', _('show topics matching keyword')),
+ ],
_('[-ec] [TOPIC]'))
def help_(ui, name=None, unknowncmd=False, full=True, **opts):
"""show help for a given topic or a help overview
@@ -3300,7 +3302,7 @@
doc = doc()
ui.write("%s\n\n" % header)
- ui.write("%s" % minirst.format(doc, textwidth, indent=4))
+ ui.write(minirst.format(doc, textwidth, indent=4))
try:
cmdutil.findcmd(name, table)
ui.write(_('\nuse "hg help -c %s" to see help for '
@@ -3350,6 +3352,18 @@
ui.write(_('use "hg help extensions" for information on enabling '
'extensions\n'))
+ kw = opts.get('keyword')
+ if kw:
+ matches = help.topicmatch(kw)
+ for t, title in (('topics', _('Topics')),
+ ('commands', _('Commands')),
+ ('extensions', _('Extensions')),
+ ('extensioncommands', _('Extension Commands'))):
+ if matches[t]:
+ ui.write('%s:\n' % title)
+ ui.write(minirst.format(minirst.maketable(matches[t])))
+ return
+
if name and name != 'shortlist':
i = None
if unknowncmd:
diff --git a/tests/test-debugcomplete.t b/tests/test-debugcomplete.t
--- a/tests/test-debugcomplete.t
+++ b/tests/test-debugcomplete.t
@@ -250,7 +250,7 @@
graft: continue, edit, log, currentdate, currentuser, date, user, tool, dry-run
grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
heads: rev, topo, active, closed, style, template
- help: extension, command
+ help: extension, command, keyword
identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure
import: strip, base, edit, force, no-commit, bypass, exact, import-branch, message, logfile, date, user, similarity
incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd, insecure, subrepos
More information about the Mercurial-devel
mailing list