remove quotes for empty StringFlags

This commit is contained in:
Ryan Schmukler
2014-04-11 15:09:59 -04:00
parent 3fa24ca4f3
commit 312151dca4
2 changed files with 16 additions and 4 deletions

11
flag.go
View File

@@ -157,7 +157,16 @@ type StringFlag struct {
}
func (f StringFlag) String() string {
return fmt.Sprintf("%s '%v'\t%v", prefixedNames(f.Name), f.Value, f.Usage)
var fmtString string
fmtString = "%s %v\t%v"
if len(f.Value) > 0 {
fmtString = "%s '%v'\t%v"
} else {
fmtString = "%s %v\t%v"
}
return fmt.Sprintf(fmtString, prefixedNames(f.Name), f.Value, f.Usage)
}
func (f StringFlag) Apply(set *flag.FlagSet) {