Skip to content

Commit

Permalink
refactor(xcmd): usage support default value
Browse files Browse the repository at this point in the history
  • Loading branch information
hui.wang committed Jan 25, 2022
1 parent dc0a152 commit abd85d7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions xcmd/explain.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,13 @@ func (c *Command) updateUsage(x *xconf.XConf) {
if usage == "" {
usage = v.Usage
}
if !xflag.IsZeroValue(v.Flag, v.DefValue) {
if v.TypeName == "string" {
usage += fmt.Sprintf(" (default %q)", v.DefValue)
} else {
usage += fmt.Sprintf(" (default %s)", v.DefValue)
}
}
line += fmt.Sprintf("|%s| %s", tag, usage)
if xutil.ContainString(c.flagLocal, v.Name) {
linesLocal = append(linesLocal, line)
Expand Down

0 comments on commit abd85d7

Please sign in to comment.