30 lines
660 B
Go
30 lines
660 B
Go
package builtin
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gitea.maximumdirect.net/eric/seriatim/internal/config"
|
|
"gitea.maximumdirect.net/eric/seriatim/internal/jsonfile"
|
|
"gitea.maximumdirect.net/eric/seriatim/internal/report"
|
|
)
|
|
|
|
type jsonOutputWriter struct{}
|
|
|
|
func (jsonOutputWriter) Name() string {
|
|
return "json"
|
|
}
|
|
|
|
func (jsonOutputWriter) Write(ctx context.Context, out any, rpt report.Report, cfg config.Config) ([]report.Event, error) {
|
|
if err := ctx.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if err := jsonfile.Write(cfg.OutputFile, out); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return []report.Event{
|
|
report.Info("output", "json", "wrote transcript JSON"),
|
|
}, nil
|
|
}
|