Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getopts should use grapheme clusters for text alignment #5516

Closed
Kimundi opened this issue Mar 23, 2013 · 8 comments
Closed

getopts should use grapheme clusters for text alignment #5516

Kimundi opened this issue Mar 23, 2013 · 8 comments
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@Kimundi
Copy link
Member

Kimundi commented Mar 23, 2013

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.

@catamorphism
Copy link
Contributor

Nominating for milestone 5, production-ready

@graydon
Copy link
Contributor

graydon commented May 23, 2013

just a bug, removing milestone/nomination.

@pnkfelix
Copy link
Member

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.

bors added a commit that referenced this issue Aug 25, 2013
…excrichton

...bytes.

(removing previous note about eff-eye-ex'ing #5516 since it actually does not do so, it just gets us half-way.)
@pnkfelix
Copy link
Member

(updating description to reflect PR #8710.)

@emberian
Copy link
Member

With the advent of libunicode this would presumably be a lot easier!

@emberian
Copy link
Member

It's also possible that we want to get rid of getops and replace it with docopt.

@emberian emberian changed the title extra::getopts should use grapheme clusters for text alignment getopts should use grapheme clusters for text alignment Jul 29, 2014
@bluss
Copy link
Member

bluss commented 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
Copy link
Member

This issue has been moved to the getopts repo: rust-lang/getopts#7

nivkner added a commit to nivkner/rust that referenced this issue Sep 30, 2017
remove FIXME(rust-lang#13101) since `assert_receiver_is_total_eq` stays.
remove FIXME(rust-lang#19649) now that stability markers render.
remove FIXME(rust-lang#13642) now the benchmarks were moved.
remove FIXME(rust-lang#6220) now that floating points can be formatted.
remove FIXME(rust-lang#18248) and write tests for `Rc<str>` and `Rc<[u8]>`
remove reference to irelevent issues in FIXME(rust-lang#1697, rust-lang#2178...)
update FIXME(rust-lang#5516) to point to getopts issue 7
update FIXME(rust-lang#7771) to point to RFC 628
update FIXME(rust-lang#19839) to point to issue 26925
oli-obk pushed a commit to oli-obk/rust that referenced this issue May 2, 2020
Add a note to the beta sections of release.md

changelog: none
oli-obk pushed a commit to oli-obk/rust that referenced this issue May 2, 2020
Rollup of 5 pull requests

Successful merges:

 - rust-lang#5408 (Downgrade match_bool to pedantic)
 - rust-lang#5505 (Avoid running cargo+internal lints when not enabled)
 - rust-lang#5516 (Add a note to the beta sections of release.md)
 - rust-lang#5517 (Deploy time travel)
 - rust-lang#5523 (Add lifetime test case for `new_ret_no_self`)

Failed merges:

r? @ghost

changelog: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

7 participants