Mercurial > hg
changeset 15022:bf1fa4ba582b
help: move 'additional help topics' code
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 04 Aug 2011 15:36:15 -0500 |
parents | 573e82fef44d |
children | 157a294444b2 |
files | mercurial/commands.py |
diffstat | 1 files changed, 15 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Thu Aug 04 15:34:30 2011 -0500 +++ b/mercurial/commands.py Thu Aug 04 15:36:15 2011 -0500 @@ -2589,14 +2589,14 @@ Returns 0 if successful. """ - option_lists = [] + optlist = [] textwidth = min(ui.termwidth(), 80) - 2 def addglobalopts(aliases): if ui.verbose: - option_lists.append((_("global options:"), globalopts)) + optlist.append((_("global options:"), globalopts)) if name == 'shortlist': - option_lists.append((_('use "hg help" for the full list ' + optlist.append((_('use "hg help" for the full list ' 'of commands'), ())) else: if name == 'shortlist': @@ -2609,7 +2609,7 @@ 'global options') % (name and " " + name or "") else: msg = _('use "hg -v help %s" to show global options') % name - option_lists.append((msg, ())) + optlist.append((msg, ())) def helpcmd(name): try: @@ -2661,7 +2661,7 @@ if not ui.quiet: # options if entry[1]: - option_lists.append((_("options:\n"), entry[1])) + optlist.append((_("options:\n"), entry[1])) addglobalopts(False) @@ -2820,10 +2820,19 @@ if text: ui.write("\n%s\n" % minirst.format(text, textwidth)) + if not name: + ui.write(_("\nadditional help topics:\n\n")) + topics = [] + for names, header, doc in help.helptable: + topics.append((sorted(names, key=len, reverse=True)[0], header)) + topics_len = max([len(s[0]) for s in topics]) + for t, desc in topics: + ui.write(" %-*s %s\n" % (topics_len, t, desc)) + # list all option lists opt_output = [] multioccur = False - for title, options in option_lists: + for title, options in optlist: opt_output.append(("\n%s" % title, None)) for option in options: if len(option) == 5: @@ -2856,15 +2865,6 @@ else: opt_output.insert(-1, (msg, None)) - if not name: - ui.write(_("\nadditional help topics:\n\n")) - topics = [] - for names, header, doc in help.helptable: - topics.append((sorted(names, key=len, reverse=True)[0], header)) - topics_len = max([len(s[0]) for s in topics]) - for t, desc in topics: - ui.write(" %-*s %s\n" % (topics_len, t, desc)) - if opt_output: colwidth = encoding.colwidth # normalize: (opt or message, desc or None, width of opt)