equal
deleted
inserted
replaced
2659 topic. |
2659 topic. |
2660 |
2660 |
2661 Returns 0 if successful. |
2661 Returns 0 if successful. |
2662 """ |
2662 """ |
2663 |
2663 |
2664 optlist = [] |
|
2665 textwidth = min(ui.termwidth(), 80) - 2 |
2664 textwidth = min(ui.termwidth(), 80) - 2 |
2666 |
2665 |
2667 # list all option lists |
2666 # list all option lists |
2668 def opttext(optlist, width): |
2667 def opttext(optlist, width): |
2669 out = [] |
2668 out = [] |
2718 else: |
2717 else: |
2719 text += "%s\n" % opt |
2718 text += "%s\n" % opt |
2720 |
2719 |
2721 return text |
2720 return text |
2722 |
2721 |
2723 def addglobalopts(aliases): |
2722 def addglobalopts(optlist, aliases): |
|
2723 if ui.quiet: |
|
2724 return [] |
|
2725 |
2724 if ui.verbose: |
2726 if ui.verbose: |
2725 optlist.append((_("global options:"), globalopts)) |
2727 optlist.append((_("global options:"), globalopts)) |
2726 if name == 'shortlist': |
2728 if name == 'shortlist': |
2727 optlist.append((_('use "hg help" for the full list ' |
2729 optlist.append((_('use "hg help" for the full list ' |
2728 'of commands'), ())) |
2730 'of commands'), ())) |
2738 else: |
2740 else: |
2739 msg = _('use "hg -v help %s" to show global options') % name |
2741 msg = _('use "hg -v help %s" to show global options') % name |
2740 optlist.append((msg, ())) |
2742 optlist.append((msg, ())) |
2741 |
2743 |
2742 def helpcmd(name): |
2744 def helpcmd(name): |
|
2745 optlist = [] |
2743 try: |
2746 try: |
2744 aliases, entry = cmdutil.findcmd(name, table, strict=unknowncmd) |
2747 aliases, entry = cmdutil.findcmd(name, table, strict=unknowncmd) |
2745 except error.AmbiguousCommand, inst: |
2748 except error.AmbiguousCommand, inst: |
2746 # py3k fix: except vars can't be used outside the scope of the |
2749 # py3k fix: except vars can't be used outside the scope of the |
2747 # except block, nor can be used inside a lambda. python issue4617 |
2750 # except block, nor can be used inside a lambda. python issue4617 |
2789 if not ui.quiet: |
2792 if not ui.quiet: |
2790 # options |
2793 # options |
2791 if entry[1]: |
2794 if entry[1]: |
2792 optlist.append((_("options:\n"), entry[1])) |
2795 optlist.append((_("options:\n"), entry[1])) |
2793 |
2796 |
2794 addglobalopts(False) |
|
2795 |
|
2796 # check if this command shadows a non-trivial (multi-line) |
2797 # check if this command shadows a non-trivial (multi-line) |
2797 # extension help text |
2798 # extension help text |
2798 try: |
2799 try: |
2799 mod = extensions.find(name) |
2800 mod = extensions.find(name) |
2800 doc = gettext(mod.__doc__) or '' |
2801 doc = gettext(mod.__doc__) or '' |
2803 'the %s extension') % (name, name) |
2804 'the %s extension') % (name, name) |
2804 ui.write('\n%s\n' % msg) |
2805 ui.write('\n%s\n' % msg) |
2805 except KeyError: |
2806 except KeyError: |
2806 pass |
2807 pass |
2807 |
2808 |
|
2809 addglobalopts(optlist, False) |
2808 ui.write(opttext(optlist, textwidth)) |
2810 ui.write(opttext(optlist, textwidth)) |
2809 |
2811 |
2810 def helplist(select=None): |
2812 def helplist(select=None): |
2811 # list of commands |
2813 # list of commands |
2812 if name == "shortlist": |
2814 if name == "shortlist": |
2851 else: |
2853 else: |
2852 ui.write('%s\n' % (util.wrap(h[f], textwidth, |
2854 ui.write('%s\n' % (util.wrap(h[f], textwidth, |
2853 initindent=' %-*s ' % (m, f), |
2855 initindent=' %-*s ' % (m, f), |
2854 hangindent=' ' * (m + 4)))) |
2856 hangindent=' ' * (m + 4)))) |
2855 |
2857 |
2856 if not ui.quiet: |
|
2857 addglobalopts(True) |
|
2858 |
|
2859 if not name: |
2858 if not name: |
2860 text = help.listexts(_('enabled extensions:'), extensions.enabled()) |
2859 text = help.listexts(_('enabled extensions:'), extensions.enabled()) |
2861 if text: |
2860 if text: |
2862 ui.write("\n%s" % minirst.format(text, textwidth)) |
2861 ui.write("\n%s" % minirst.format(text, textwidth)) |
2863 |
2862 |
2867 topics.append((sorted(names, key=len, reverse=True)[0], header)) |
2866 topics.append((sorted(names, key=len, reverse=True)[0], header)) |
2868 topics_len = max([len(s[0]) for s in topics]) |
2867 topics_len = max([len(s[0]) for s in topics]) |
2869 for t, desc in topics: |
2868 for t, desc in topics: |
2870 ui.write(" %-*s %s\n" % (topics_len, t, desc)) |
2869 ui.write(" %-*s %s\n" % (topics_len, t, desc)) |
2871 |
2870 |
|
2871 optlist = [] |
|
2872 addglobalopts(optlist, True) |
2872 ui.write(opttext(optlist, textwidth)) |
2873 ui.write(opttext(optlist, textwidth)) |
2873 |
2874 |
2874 def helptopic(name): |
2875 def helptopic(name): |
2875 for names, header, doc in help.helptable: |
2876 for names, header, doc in help.helptable: |
2876 if name in names: |
2877 if name in names: |