Implement normalize output conversion

This commit is contained in:
2026-05-09 12:32:18 +00:00
parent c132f3fd5d
commit 6c780f6293
3 changed files with 387 additions and 8 deletions

View File

@@ -2,7 +2,9 @@ package normalize
import (
"context"
"encoding/json"
"fmt"
"os"
"gitea.maximumdirect.net/eric/seriatim/internal/config"
)
@@ -14,10 +16,34 @@ func Run(ctx context.Context, cfg config.NormalizeConfig) error {
return err
}
if _, err := ParseFile(cfg.InputFile); err != nil {
parsed, err := ParseFile(cfg.InputFile)
if err != nil {
return err
}
// TODO: Implement transcript normalization transformation.
return fmt.Errorf("normalize command is not implemented yet")
output, err := Build(parsed, cfg)
if err != nil {
return err
}
if err := writeOutputJSON(cfg.OutputFile, output); err != nil {
return err
}
return nil
}
func writeOutputJSON(path string, value any) error {
file, err := os.Create(path)
if err != nil {
return err
}
defer file.Close()
encoder := json.NewEncoder(file)
encoder.SetIndent("", " ")
if err := encoder.Encode(value); err != nil {
return fmt.Errorf("encode normalize output JSON: %w", err)
}
return nil
}