2026-05-10 23:12:46 +00:00
|
|
|
package cli
|
|
|
|
|
|
|
|
|
|
import (
|
2026-05-11 14:22:22 +00:00
|
|
|
"context"
|
2026-05-10 23:12:46 +00:00
|
|
|
"fmt"
|
|
|
|
|
"io"
|
2026-05-10 23:19:59 +00:00
|
|
|
|
2026-10-11 01:40:38 +00:00
|
|
|
"gitea.maximumdirect.net/eric/audita/v3/internal/core/schema"
|
2026-11-10 16:55:56 +00:00
|
|
|
commandkit "go.maximumdirect.net/commandkit"
|
2026-05-10 23:12:46 +00:00
|
|
|
)
|
|
|
|
|
|
2026-05-11 00:41:29 +00:00
|
|
|
func sourceToCanonicalTranscript(source *schema.SourceTranscript) *schema.Transcript {
|
|
|
|
|
segments := make([]schema.Segment, len(source.Segments))
|
|
|
|
|
for i, s := range source.Segments {
|
|
|
|
|
id := i + 1
|
|
|
|
|
if s.ID != nil {
|
|
|
|
|
id = *s.ID
|
|
|
|
|
}
|
|
|
|
|
segments[i] = schema.Segment{
|
|
|
|
|
ID: id,
|
|
|
|
|
Speaker: s.Speaker,
|
|
|
|
|
Start: s.Start,
|
|
|
|
|
End: s.End,
|
|
|
|
|
Text: s.Text,
|
|
|
|
|
Categories: s.Categories,
|
|
|
|
|
}
|
2026-05-10 23:27:54 +00:00
|
|
|
}
|
2026-05-11 00:41:29 +00:00
|
|
|
return &schema.Transcript{Segments: segments}
|
2026-05-10 23:24:48 +00:00
|
|
|
}
|
|
|
|
|
|
2026-11-10 16:55:56 +00:00
|
|
|
// Run executes the application with the provided arguments and streams.
|
2026-09-24 17:27:11 +00:00
|
|
|
func Run(ctx context.Context, args []string, stdout, stderr io.Writer) int {
|
2026-11-10 16:55:56 +00:00
|
|
|
app, err := buildApplication()
|
2026-09-24 01:38:49 +00:00
|
|
|
if err != nil {
|
2026-11-10 16:55:56 +00:00
|
|
|
fmt.Fprintln(stderr, err)
|
2026-05-13 12:36:20 +00:00
|
|
|
return 1
|
|
|
|
|
}
|
2026-11-10 16:55:56 +00:00
|
|
|
return app.Execute(ctx, args, commandkit.Streams{Out: stdout, Err: stderr}).Status
|
2026-05-10 23:12:46 +00:00
|
|
|
}
|