jessevdk / go-flags

go command line option parser
http://godoc.org/github.com/jessevdk/go-flags
BSD 3-Clause "New" or "Revised" License
2.56k stars 305 forks source link

Support unicode chars in WriteHelp #401

Open JasonMing opened 8 months ago

JasonMing commented 8 months ago

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