From addd467e5b30964f47a54ceac0dfcb689b0b1928 Mon Sep 17 00:00:00 2001 From: Aaron Berns Date: Tue, 20 Aug 2019 10:03:29 -0400 Subject: [PATCH] update checkRequiredFlags function to check RequiredFlagsErr field and return map of missing flag names with matching bool for RequiredFlagsErr value --- context.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/context.go b/context.go index db7cd69..85ba419 100644 --- a/context.go +++ b/context.go @@ -310,12 +310,16 @@ func (e *errRequiredFlags) getMissingFlags() []string { } func checkRequiredFlags(flags []Flag, context *Context) requiredFlagsErr { - var missingFlags []string + missingFlags := make(map[string]bool) for _, f := range flags { if rf, ok := f.(RequiredFlag); ok && rf.IsRequired() { key := strings.Split(f.GetName(), ",")[0] if !context.IsSet(key) { - missingFlags = append(missingFlags, key) + if re, ok := f.(RequiredFlagsErr); ok && re.FlagsErrRequired() { + missingFlags[key] = true + } else { + missingFlags[key] = false + } } } }