validateFile validates a single file and displays results
(filename string, timestamp string)
| 198 | |
| 199 | // validateFile validates a single file and displays results |
| 200 | func (fw *FileWatcher) validateFile(filename string, timestamp string) { |
| 201 | if fw.opts.ValidatorOpts == nil { |
| 202 | return |
| 203 | } |
| 204 | |
| 205 | validator := NewValidator(fw.opts.Out, fw.opts.Err, *fw.opts.ValidatorOpts) |
| 206 | fileResult := validator.validateFile(filename) |
| 207 | |
| 208 | if fileResult.Error != nil { |
| 209 | fmt.Fprintf(fw.opts.Err, "[%s] %s %s - %v\n", |
| 210 | timestamp, colorRed("✗"), filename, fileResult.Error) |
| 211 | return |
| 212 | } |
| 213 | |
| 214 | if fileResult.Valid { |
| 215 | fmt.Fprintf(fw.opts.Out, "[%s] %s %s - Valid\n", |
| 216 | timestamp, colorGreen("✓"), filename) |
| 217 | } else { |
| 218 | fmt.Fprintf(fw.opts.Out, "[%s] %s %s - Invalid\n", |
| 219 | timestamp, colorRed("✗"), filename) |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | // formatFile formats a single file and displays results |
| 224 | func (fw *FileWatcher) formatFile(filename string, timestamp string) { |
no test coverage detected