From 4243004e948d92e86224caa1f83f625480c43d5e Mon Sep 17 00:00:00 2001 From: Inhere Date: Thu, 29 Sep 2022 14:29:33 +0800 Subject: [PATCH] chore: fix example run error and cmd help message error --- gcli.go | 3 +++ gflag/flags.go | 9 +++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gcli.go b/gcli.go index 6c9a808..d0beebd 100644 --- a/gcli.go +++ b/gcli.go @@ -77,6 +77,9 @@ type Flags = gflag.Flags // FlagMeta alias of the gflag.Option type FlagMeta = gflag.Option +// FlagsConfig alias of the gflag.FlagsConfig +type FlagsConfig = gflag.FlagsConfig + // NewFlags create new gflag.Flags func NewFlags(nameWithDesc ...string) *gflag.Flags { return gflag.New(nameWithDesc...) diff --git a/gflag/flags.go b/gflag/flags.go index 98ef913..626a79d 100644 --- a/gflag/flags.go +++ b/gflag/flags.go @@ -746,14 +746,11 @@ func (fs *Flags) formatOneFlag(f *flag.Flag) (s string) { // --- build description if desc == "" { desc = defaultDesc + } else { + desc = strings.Replace(strutil.UpperFirst(desc), "\n", nlIndent, -1) } - // flag is required - if meta.Required { - s = "*" + s - } - - s += strings.Replace(strutil.UpperFirst(desc), "\n", nlIndent, -1) + s += getRequiredMark(meta.Required) + desc // ---- append default value if isZero, isStr := cflag.IsZeroValue(f, f.DefValue); !isZero {