coder / serpent

CLI framework for scale and configurability inspired by Cobra
Creative Commons Zero v1.0 Universal
6 stars 1 forks source link

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

Open b7q-test opened 3 months ago

b7q-test commented 3 months ago

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.
ammario commented 3 months ago

Hey, this is a valid problem and a vestige of the library's past presence within coder/coder. We should move this linting logic over there and be unopinionated here.