Files
audita/internal/cli/run.go

40 lines
951 B
Go

package cli
import (
"context"
"fmt"
"io"
"gitea.maximumdirect.net/eric/audita/v3/internal/core/schema"
commandkit "go.maximumdirect.net/commandkit"
)
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,
}
}
return &schema.Transcript{Segments: segments}
}
// Run executes the application with the provided arguments and streams.
func Run(ctx context.Context, args []string, stdout, stderr io.Writer) int {
app, err := buildApplication()
if err != nil {
fmt.Fprintln(stderr, err)
return 1
}
return app.Execute(ctx, args, commandkit.Streams{Out: stdout, Err: stderr}).Status
}