From 6b8413cdba8b86c2bb248b2417941654e335f89b Mon Sep 17 00:00:00 2001 From: Masahiro331 Date: Fri, 11 Feb 2022 05:50:32 +0900 Subject: [PATCH] fix(subject): fix doc format (#8) --- main.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 92afd4a..2f9d977 100644 --- a/main.go +++ b/main.go @@ -108,10 +108,22 @@ type TypeRule struct { type TypeRules []TypeRule +func (typeRules TypeRules) getLongestTypeLength() int { + length := 0 + for _, tr := range typeRules { + if length < len(tr.Type) { + length = len(tr.Type) + } + } + return length +} + func (typeRules TypeRules) String() string { ret := "Allowed values\n" + + spaceLength := typeRules.getLongestTypeLength() + 2 for _, tr := range typeRules { - ret += fmt.Sprintf("%s\t%s\n", textBrightYellow(tr.Type), tr.Description) + ret += fmt.Sprintf("%s%s%s\n", textBrightYellow(tr.Type), strings.Repeat(" ", spaceLength-len(tr.Type)), tr.Description) } return ret