##// END OF EJS Templates
help: add --keyword (-k) for searching help
Augie Fackler -
r16711:497deec2 default
parent child Browse files
Show More
@@ -3063,7 +3063,9 b' def heads(ui, repo, *branchrevs, **opts)'
3063
3063
3064 @command('help',
3064 @command('help',
3065 [('e', 'extension', None, _('show only help for extensions')),
3065 [('e', 'extension', None, _('show only help for extensions')),
3066 ('c', 'command', None, _('show only help for commands'))],
3066 ('c', 'command', None, _('show only help for commands')),
3067 ('k', 'keyword', '', _('show topics matching keyword')),
3068 ],
3067 _('[-ec] [TOPIC]'))
3069 _('[-ec] [TOPIC]'))
3068 def help_(ui, name=None, unknowncmd=False, full=True, **opts):
3070 def help_(ui, name=None, unknowncmd=False, full=True, **opts):
3069 """show help for a given topic or a help overview
3071 """show help for a given topic or a help overview
@@ -3309,7 +3311,7 b' def help_(ui, name=None, unknowncmd=Fals'
3309 doc = doc()
3311 doc = doc()
3310
3312
3311 ui.write("%s\n\n" % header)
3313 ui.write("%s\n\n" % header)
3312 ui.write("%s" % minirst.format(doc, textwidth, indent=4))
3314 ui.write(minirst.format(doc, textwidth, indent=4))
3313 try:
3315 try:
3314 cmdutil.findcmd(name, table)
3316 cmdutil.findcmd(name, table)
3315 ui.write(_('\nuse "hg help -c %s" to see help for '
3317 ui.write(_('\nuse "hg help -c %s" to see help for '
@@ -3359,6 +3361,18 b' def help_(ui, name=None, unknowncmd=Fals'
3359 ui.write(_('use "hg help extensions" for information on enabling '
3361 ui.write(_('use "hg help extensions" for information on enabling '
3360 'extensions\n'))
3362 'extensions\n'))
3361
3363
3364 kw = opts.get('keyword')
3365 if kw:
3366 matches = help.topicmatch(kw)
3367 for t, title in (('topics', _('Topics')),
3368 ('commands', _('Commands')),
3369 ('extensions', _('Extensions')),
3370 ('extensioncommands', _('Extension Commands'))):
3371 if matches[t]:
3372 ui.write('%s:\n' % title)
3373 ui.write(minirst.format(minirst.maketable(matches[t])))
3374 return
3375
3362 if name and name != 'shortlist':
3376 if name and name != 'shortlist':
3363 i = None
3377 i = None
3364 if unknowncmd:
3378 if unknowncmd:
@@ -69,7 +69,7 b' def topicmatch(kw):'
69 if lowercontains(name) or lowercontains(docs):
69 if lowercontains(name) or lowercontains(docs):
70 results['extensions'].append((name, _(docs).splitlines()[0]))
70 results['extensions'].append((name, _(docs).splitlines()[0]))
71 for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems():
71 for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems():
72 if kw in cmd or lowercontains(entry[2]):
72 if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])):
73 cmdname = cmd.split('|')[0].lstrip('^')
73 cmdname = cmd.split('|')[0].lstrip('^')
74 results['extensioncommands'].append(
74 results['extensioncommands'].append(
75 (cmdname, _(getattr(cmd, '__doc__', ''))))
75 (cmdname, _(getattr(cmd, '__doc__', ''))))
@@ -250,7 +250,7 b' Show all commands + options'
250 graft: continue, edit, log, currentdate, currentuser, date, user, tool, dry-run
250 graft: continue, edit, log, currentdate, currentuser, date, user, tool, dry-run
251 grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
251 grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
252 heads: rev, topo, active, closed, style, template
252 heads: rev, topo, active, closed, style, template
253 help: extension, command
253 help: extension, command, keyword
254 identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure
254 identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure
255 import: strip, base, edit, force, no-commit, bypass, exact, import-branch, message, logfile, date, user, similarity
255 import: strip, base, edit, force, no-commit, bypass, exact, import-branch, message, logfile, date, user, similarity
256 incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd, insecure, subrepos
256 incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd, insecure, subrepos
General Comments 0
You need to be logged in to leave comments. Login now