Mercurial > hg
comparison mercurial/commands.py @ 8039:18081ce1e630
commands: automatically word-wrap cmdline options
Some of the descriptions of command line options were getting quite
long, and when translated they are likely to grow even longer. This
word-wraps them at 70 characters, just like the help texts.
We could have opted to wrap them at the terminal width instead, but I
think it looks better to have them be consistent with the help texts.
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Thu, 09 Apr 2009 14:43:02 +0200 |
parents | 2ee6769afe82 |
children | 545fb915fe16 |
comparison
equal
deleted
inserted
replaced
8038:2ee6769afe82 | 8039:18081ce1e630 |
---|---|
5 # This software may be used and distributed according to the terms | 5 # This software may be used and distributed according to the terms |
6 # of the GNU General Public License, incorporated herein by reference. | 6 # of the GNU General Public License, incorporated herein by reference. |
7 | 7 |
8 from node import hex, nullid, nullrev, short | 8 from node import hex, nullid, nullrev, short |
9 from i18n import _, gettext | 9 from i18n import _, gettext |
10 import os, re, sys | 10 import os, re, sys, textwrap |
11 import hg, util, revlog, bundlerepo, extensions, copies, context, error | 11 import hg, util, revlog, bundlerepo, extensions, copies, context, error |
12 import difflib, patch, time, help, mdiff, tempfile, url, encoding | 12 import difflib, patch, time, help, mdiff, tempfile, url, encoding |
13 import archival, changegroup, cmdutil, hgweb.server, sshserver, hbisect | 13 import archival, changegroup, cmdutil, hgweb.server, sshserver, hbisect |
14 import merge as merge_ | 14 import merge as merge_ |
15 | 15 |
1530 | 1530 |
1531 if opt_output: | 1531 if opt_output: |
1532 opts_len = max([len(line[0]) for line in opt_output if line[1]] or [0]) | 1532 opts_len = max([len(line[0]) for line in opt_output if line[1]] or [0]) |
1533 for first, second in opt_output: | 1533 for first, second in opt_output: |
1534 if second: | 1534 if second: |
1535 ui.write(" %-*s %s\n" % (opts_len, first, second)) | 1535 # wrap descriptions at 70 characters, just like the |
1536 # main help texts | |
1537 second = textwrap.wrap(second, width=70 - opts_len - 3) | |
1538 pad = '\n' + ' ' * (opts_len + 3) | |
1539 ui.write(" %-*s %s\n" % (opts_len, first, pad.join(second))) | |
1536 else: | 1540 else: |
1537 ui.write("%s\n" % first) | 1541 ui.write("%s\n" % first) |
1538 | 1542 |
1539 def identify(ui, repo, source=None, | 1543 def identify(ui, repo, source=None, |
1540 rev=None, num=None, id=None, branch=None, tags=None): | 1544 rev=None, num=None, id=None, branch=None, tags=None): |