Closed suntong closed 8 years ago
You can replace ` with " like this:
Desc: "Golang package manager",
Text: " gogo is a new golang package manager\n very very good",
It's equivalent to:
Desc: "Golang package manager",
Text: ` gogo is a new golang package manager
very very good`,
` is used to represent raw string in golang.
In fact, there is not any handle for escaping:
Help goptions.Help `goptions:"-h, --help, description='Show this help\n\nSub-commands (Verbs):\n\n\texecute\t\tExecute it\n\t\t\tExecute the given command\n\n\tdelete\t\tDelete it'"`
Try this:
// main.go
package main
import (
"github.com/mkideal/cli"
)
type argT struct {
cli.Helper
Hello string `cli:"hello" usage:"no escaping\nhere is a new line"`
}
func main() {
cli.Run(new(argT), func(ctx *cli.Context) error {
return nil
})
}
go run main.go -h
ops, yes. Silly me. :(
Hi 王仕晋,
For the following,
I'll get
The
github.com/voxelbrain/goptions
was able to handle the escaping nicely, so should CLI. After all, the escaping sequence is a fundamental feature of modern programming language.I'll change my sample code at https://github.com/suntong/lang/blob/master/lang/Go/src/sys/CommandLineGoptions.go to show that goptions handles the escaping nicely.
Done,
Please enable escape sequence handling.
Thanks