Skip to content

Commit 4095234

Browse files
remove header for table, improve string fromatting, remove redundant flag path from suggestions, add check for flagtype
Signed-off-by: Adityasinghvats <131326798+Adityasinghvats@users.noreply.github.com>
1 parent a9e4fe6 commit 4095234

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

internal/flagset/flagset.go

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,7 @@ func (fs *Flagset) UnmarshalJSON(data []byte) error {
135135
}
136136
func FormatValidationError(issues []manifest.ValidationError) string {
137137
var sb strings.Builder
138-
sb.WriteString("flag manifest validation failed:\n")
139-
sb.WriteString("+--------------+-------------+------------------+\n")
140-
sb.WriteString("| flag type | flag path | error messages |\n")
141-
sb.WriteString("+--------------+-------------+------------------+\n")
138+
sb.WriteString("flag manifest validation failed:\n\n")
142139

143140
// Group messages by flag path
144141
grouped := make(map[string]struct {
@@ -163,17 +160,16 @@ func FormatValidationError(issues []manifest.ValidationError) string {
163160
// Format each row
164161
for _, path := range paths {
165162
entry := grouped[path]
166-
sb.WriteString(fmt.Sprintf("- [%-12s] [%-11s]\n \t~ %-16s \n\t\t%s\n \t\t\t%s:\n \t\t\t\t%s\n\t\t\t\t%s \n\n",
167-
entry.flagType,
168-
path,
169-
strings.Join(entry.messages, ", \n\t~ "),
170-
"Suggestions:",
163+
flagType := entry.flagType
164+
if flagType == "" {
165+
flagType = "missing"
166+
}
167+
sb.WriteString(fmt.Sprintf(
168+
"- flagType: %s\n flagPath: %s\n errors:\n ~ %s\n \tSuggestions:\n \t- flagType: boolean\n \t- defaultValue: true\n\n",
169+
flagType,
171170
path,
172-
"flagType: boolean",
173-
"defaultValue: true",
171+
strings.Join(entry.messages, "\n ~ "),
174172
))
175173
}
176-
177-
sb.WriteString("+--------------+-------------+------------------+\n")
178174
return sb.String()
179175
}

0 commit comments

Comments
 (0)