Closed
Description
It should at minimum align to number of codepoints (characters), (and now that PR #8710 has landed, it should be doing that minimum), but the only correct thing would be to align to grapheme clusters.
test case
extern mod extra;
use extra::getopts::groups;
fn main() {
let optgroups = ~[
groups::optflag("a", "apple", "apple description"),
groups::optflag("b", "banana\u00AB", "banana description"),
groups::optflag("c", "br\xfbl\xe9e", "br\xfbl\xe9e quite long description"),
groups::optflag("k", "kiwi\u20AC", "kiwi description"),
groups::optflag("o", "orange\u2039", "orange description"),
groups::optflag("r",
"raspberry-but-making-this-option-way-too-long",
"raspberry description is also quite long indeed longer than every other piece of text we might encounter here and thus will be automatically broken up"),
];
println(usage("Usage: fruits", optgroups));
}
current output:
% rustc /tmp/issue5516.rs && /tmp/issue5516 --help
warning: no debug symbols in executable (-arch x86_64)
Usage: fruits
Options:
-a --apple apple description
-b --banana« banana description
-c --brûlée brûlée quite long descripti
-k --kiwi€ kiwi description
-o --orange‹ orange description
-r --raspberry-but-making-this-option-way-too-long
raspberry description is also quite long indeed longer
than every other piece of text we might encounter here
and thus will be automatically broken up
Note that in addition to things failing to line up, it is also cutting off the end of the text for the brûlée case. That issue should also be fixed.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
catamorphism commentedon May 23, 2013
Nominating for milestone 5, production-ready
graydon commentedon May 23, 2013
just a bug, removing milestone/nomination.
pnkfelix commentedon Aug 23, 2013
Visiting for triage, email from 2013-08-19
The grapheme-oriented solution is blocked on #7043.
But we can at least put in the codepoint-oriented solution for the time being.
auto merge of #8710 : pnkfelix/rust/fsk-issue5516-codepoint-fix, r=al…
pnkfelix commentedon Nov 22, 2013
(updating description to reflect PR #8710.)
emberian commentedon Jul 29, 2014
With the advent of
libunicode
this would presumably be a lot easier!emberian commentedon Jul 29, 2014
It's also possible that we want to get rid of
getops
and replace it withdocopt
.[-]extra::getopts should use grapheme clusters for text alignment [/-][+]getopts should use grapheme clusters for text alignment [/+]bluss commentedon Jul 29, 2014
Note that graphemes don't tell you the display width of text. There is a rudimentary codepoint-oriented width function in libunicode though.
steveklabnik commentedon Jan 21, 2015
This issue has been moved to the getopts repo: rust-lang/getopts#7
5 remaining items