MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / formatFile

Method formatFile

cmd/gosqlx/cmd/watch.go:224–245  ·  view source on GitHub ↗

formatFile formats a single file and displays results

(filename string, timestamp string)

Source from the content-addressed store, hash-verified

222
223// formatFile formats a single file and displays results
224func (fw *FileWatcher) formatFile(filename string, timestamp string) {
225 if fw.opts.FormatterOpts == nil {
226 return
227 }
228
229 formatter := NewFormatter(fw.opts.Out, fw.opts.Err, *fw.opts.FormatterOpts)
230 fileResult := formatter.formatFile(filename)
231
232 if fileResult.Error != nil {
233 fmt.Fprintf(fw.opts.Err, "[%s] %s %s - %v\n",
234 timestamp, colorRed("✗"), filename, fileResult.Error)
235 return
236 }
237
238 if fileResult.Changed {
239 fmt.Fprintf(fw.opts.Out, "[%s] %s %s - Formatted\n",
240 timestamp, colorGreen("✓"), filename)
241 } else {
242 fmt.Fprintf(fw.opts.Out, "[%s] %s %s - No changes needed\n",
243 timestamp, colorCyan("→"), filename)
244 }
245}
246
247// processAllFiles runs initial processing on all watched files
248func (fw *FileWatcher) processAllFiles() error {

Callers 2

processFileMethod · 0.95
processAllFilesMethod · 0.95

Calls 5

formatFileMethod · 0.95
colorRedFunction · 0.85
colorGreenFunction · 0.85
colorCyanFunction · 0.85
NewFormatterFunction · 0.70

Tested by

no test coverage detected