Mercurial > hg
changeset 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 |
files | mercurial/commands.py tests/test-extension.out tests/test-record.out |
diffstat | 3 files changed, 12 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Thu Apr 09 10:48:07 2009 +0200 +++ b/mercurial/commands.py Thu Apr 09 14:43:02 2009 +0200 @@ -7,7 +7,7 @@ from node import hex, nullid, nullrev, short from i18n import _, gettext -import os, re, sys +import os, re, sys, textwrap import hg, util, revlog, bundlerepo, extensions, copies, context, error import difflib, patch, time, help, mdiff, tempfile, url, encoding import archival, changegroup, cmdutil, hgweb.server, sshserver, hbisect @@ -1532,7 +1532,11 @@ opts_len = max([len(line[0]) for line in opt_output if line[1]] or [0]) for first, second in opt_output: if second: - ui.write(" %-*s %s\n" % (opts_len, first, second)) + # wrap descriptions at 70 characters, just like the + # main help texts + second = textwrap.wrap(second, width=70 - opts_len - 3) + pad = '\n' + ' ' * (opts_len + 3) + ui.write(" %-*s %s\n" % (opts_len, first, pad.join(second))) else: ui.write("%s\n" % first)
--- a/tests/test-extension.out Thu Apr 09 10:48:07 2009 +0200 +++ b/tests/test-extension.out Thu Apr 09 14:43:02 2009 +0200 @@ -40,7 +40,8 @@ global options: -R --repository repository root directory or symbolic path name --cwd change working directory - -y --noninteractive do not prompt, assume 'yes' for any required answers + -y --noninteractive do not prompt, assume 'yes' for any required + answers -q --quiet suppress output -v --verbose enable additional output --config set/override config option
--- a/tests/test-record.out Thu Apr 09 10:48:07 2009 +0200 +++ b/tests/test-record.out Thu Apr 09 14:43:02 2009 +0200 @@ -27,8 +27,10 @@ options: - -A --addremove mark new/missing files as added/removed before committing - --close-branch mark a branch as closed, hiding it from the branch list + -A --addremove mark new/missing files as added/removed before + committing + --close-branch mark a branch as closed, hiding it from the branch + list -I --include include names matching the given patterns -X --exclude exclude names matching the given patterns -m --message use <text> as commit message