From 7d6a604106e44732edc0a76f4a4800c8c27ddfbe Mon Sep 17 00:00:00 2001 From: Ajitem Sahasrabuddhe Date: Wed, 11 Sep 2019 08:59:51 +0530 Subject: [PATCH] Fix #878 --- context.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/context.go b/context.go index db7cd69..485f529 100644 --- a/context.go +++ b/context.go @@ -313,9 +313,17 @@ func checkRequiredFlags(flags []Flag, context *Context) requiredFlagsErr { var missingFlags []string 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) + key := strings.Split(f.GetName(), ",") + if len(key) > 1 { + // has short name + if !context.IsSet(strings.TrimSpace(key[0])) && !context.IsSet(strings.TrimSpace(key[1])) { + missingFlags = append(missingFlags, key[0]) + } + } else { + // does not have short name + if !context.IsSet(strings.TrimSpace(key[0])) { + missingFlags = append(missingFlags, key[0]) + } } } }