Skip to content

Support unicode chars in WriteHelp #401

Description

@JasonMing

WriteHelp function will auto wrap and align the description that longer than terminal's width.
When multi-byte character in the description, like emoji or Chinese, the wrapping will be wrong.

func main() {
	var opt struct {
		WorkerId uint64 `short:"w" long:"worker" description:"01234567891123456789212345678931234567894123456789512345678961❤3456789"`
	}

	p := flags.NewParser(&opt, flags.HelpFlag|flags.PrintErrors)
	p.WriteHelp(os.Stdout)
}

Output:

Usage:
  example [OPTIONS]

Application Options:
  -w, --worker= 01234567891123456789212345678931234567894123456789512345678961�-

                ��3456789

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions