Default value incorrect when printing usage
chrjen opened this issue · 0 comments
chrjen commented
Version: 0.2.7
The value Hello, %s!
as a default value seems to be treated as a format string when it really should
just be printed as is.
Example code:
package main
import (
"fmt"
"os"
"github.com/mkideal/cli"
)
type argT struct {
Format string `cli:"f,format" dft:"Hello, %s!" usage:"format for greeting"`
}
func main() {
os.Exit(cli.Run(new(argT), func(ctx *cli.Context) error {
argv := ctx.Argv().(*argT)
fmt.Println(argv.Format)
fmt.Println("==================")
ctx.WriteUsage()
return nil
}))
}
Expected output:
Hello, %s!
==================
Options:
-f, --format[=Hello, %s!] format for greeting
Actual output:
Hello, %s!
==================
Options:
-f, --format[=Hello, %!s(MISSING)!] format for greeting
It prints out Hello, %!s(MISSING)!
instead.