Skip to content

Support for Non-English Characters in Option Descriptions within command.go #11

Open
@b7q-test

Description

@b7q-test

I'm working with the serpent library, particularly focusing on handling command-line options as defined within the command.go file of your project. I've encountered an issue that arises from the enforcement of rules concerning the format of option descriptions:

if opt.Description != "" {
    // Enforce that description uses sentence form.
    if unicode.IsLower(rune(opt.Description[0])) {
        merr = errors.Join(merr, xerrors.Errorf("option %q description should start with a capital letter", opt.Name))
    }
    if !strings.HasSuffix(opt.Description, ".") {
        merr = errors.Join(merr, xerrors.Errorf("option %q description should end with a period", opt.Name))
    }
}
Located in command.go, this code enforces that each option description starts with a capital letter and ends with a period. This rule aligns well with descriptions written in English. However, it becomes problematic for descriptions in non-English languages, especially for those that utilize non-Latin scripts (such as Chinese, Japanese, Arabic, etc.).

The validation errors occur because the current implementation assumes the use of English sentence structure and punctuation, which does not universally apply to all languages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions