outputValidationText outputs validation results in human-readable text format
(result *validator.ValidationResult, quiet bool)
| 123 | |
| 124 | // outputValidationText outputs validation results in human-readable text format |
| 125 | func outputValidationText(result *validator.ValidationResult, quiet bool) { |
| 126 | r := getRenderer() |
| 127 | |
| 128 | if len(result.Issues) == 0 { |
| 129 | if !quiet { |
| 130 | fmt.Printf("%s All %d task(s) are valid\n", formatSuccess("✓", r), result.TaskCount) |
| 131 | } |
| 132 | return |
| 133 | } |
| 134 | |
| 135 | // Group issues by level |
| 136 | errors := []validator.ValidationIssue{} |
| 137 | warnings := []validator.ValidationIssue{} |
| 138 | |
| 139 | for _, issue := range result.Issues { |
| 140 | if issue.Level == validator.LevelError { |
| 141 | errors = append(errors, issue) |
| 142 | } else if issue.Level == validator.LevelWarning { |
| 143 | warnings = append(warnings, issue) |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | // Print errors |
| 148 | if len(errors) > 0 { |
| 149 | fmt.Printf("\n%s Found %d error(s):\n\n", formatError("❌", r), len(errors)) |
| 150 | for _, issue := range errors { |
| 151 | printIssue(issue, r) |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | // Print warnings |
| 156 | if len(warnings) > 0 { |
| 157 | fmt.Printf("\n%s Found %d warning(s):\n\n", formatWarning("⚠️", r), len(warnings)) |
| 158 | for _, issue := range warnings { |
| 159 | printIssue(issue, r) |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | // Print summary |
| 164 | fmt.Println() |
| 165 | if result.Errors > 0 { |
| 166 | fmt.Printf("Validated %d task(s): %s", result.TaskCount, |
| 167 | formatError(fmt.Sprintf("%d error(s)", result.Errors), r)) |
| 168 | if result.Warnings > 0 { |
| 169 | fmt.Printf(", %s", formatWarning(fmt.Sprintf("%d warning(s)", result.Warnings), r)) |
| 170 | } |
| 171 | fmt.Println() |
| 172 | } else if result.Warnings > 0 { |
| 173 | fmt.Printf("Validated %d task(s) with %s\n", result.TaskCount, |
| 174 | formatWarning(fmt.Sprintf("%d warning(s)", result.Warnings), r)) |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | // printIssue prints a single validation issue |
| 179 | func printIssue(issue validator.ValidationIssue, r *lipgloss.Renderer) { |