Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

getopts should use grapheme clusters for text alignment  #5516

Closed

Description

@Kimundi

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.

Activity

  1. catamorphism commented on May 23, 2013

    @catamorphism
    Contributor

    Nominating for milestone 5, production-ready

  2. graydon commented on May 23, 2013

    @graydon
    Contributor

    just a bug, removing milestone/nomination.

  3. pnkfelix commented on Aug 23, 2013

    @pnkfelix
    Contributor

    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.

  4. added a commit that references this issue on Aug 25, 2013
  5. pnkfelix commented on Nov 22, 2013

    @pnkfelix
    Contributor

    (updating description to reflect PR #8710.)

  6. emberian commented on Jul 29, 2014

    @emberian
    Contributor

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

  7. emberian commented on Jul 29, 2014

    @emberian
    Contributor

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

  8. changed the title [-]extra::getopts should use grapheme clusters for text alignment [/-] [+]getopts should use grapheme clusters for text alignment [/+] on Jul 29, 2014
  9. bluss commented on Jul 29, 2014

    @bluss
    Contributor

    Note that graphemes don't tell you the display width of text. There is a rudimentary codepoint-oriented width function in libunicode though.

  10. steveklabnik commented on Jan 21, 2015

    @steveklabnik
    Contributor

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

  11. added 2 commits that reference this issue on May 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-easy

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions