Add reporting and debug settings with context-aware CLI selection
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -23,7 +24,6 @@ type configInput struct {
|
||||
TranscriptPath string
|
||||
GlossaryPath string
|
||||
OutputPath string
|
||||
ReportPath string
|
||||
Overrides []ck.Override
|
||||
}
|
||||
|
||||
@@ -61,12 +61,16 @@ func parseConfigInput(command string, args []string, output io.Writer) (configIn
|
||||
"spoken-word-confidence-threshold": ck.Keys("thresholds", "spoken_word"),
|
||||
"grammar-confidence-threshold": ck.Keys("thresholds", "grammar"),
|
||||
"transcript-description": ck.Keys("context", "description"),
|
||||
"reporting": ck.Keys("reporting", "enabled"),
|
||||
"report-dir": ck.Keys("reporting", "stdout_dir"),
|
||||
"debug": ck.Keys("diagnostics", "debug"),
|
||||
"work-dir": ck.Keys("diagnostics", "work_dir"),
|
||||
"work-dir-retention": ck.Keys("diagnostics", "retention"),
|
||||
"modules": ck.Keys("pipeline", "modules"),
|
||||
}
|
||||
for name := range settingPaths {
|
||||
switch name {
|
||||
case "reporting", "debug":
|
||||
fs.Bool(name, false, "Setting override")
|
||||
case "validation-max-prompt-tokens", "target-sections", "max-section-tokens", "min-section-tokens", "normalize-max-segment-tokens":
|
||||
fs.Int(name, 0, "Setting override")
|
||||
case "normalize-max-segment-gap", "normalize-ellipsis-gap", "normalize-max-segment-duration", "glossary-confidence-threshold", "homophones-confidence-threshold", "spoken-word-confidence-threshold", "grammar-confidence-threshold":
|
||||
@@ -78,7 +82,6 @@ func parseConfigInput(command string, args []string, output io.Writer) (configIn
|
||||
if command == "process" {
|
||||
fs.String("glossary", "", "Glossary YAML file")
|
||||
fs.String("output", "", "Corrected transcript output file")
|
||||
fs.String("report-json", "", "Process report output file")
|
||||
}
|
||||
parseArgs := args
|
||||
front := ""
|
||||
@@ -102,7 +105,6 @@ func parseConfigInput(command string, args []string, output io.Writer) (configIn
|
||||
input.TranscriptPath = positions[0]
|
||||
input.GlossaryPath = fs.Lookup("glossary").Value.String()
|
||||
input.OutputPath = fs.Lookup("output").Value.String()
|
||||
input.ReportPath = fs.Lookup("report-json").Value.String()
|
||||
if strings.TrimSpace(input.GlossaryPath) == "" {
|
||||
return configInput{}, false, fmt.Errorf("--glossary is required")
|
||||
}
|
||||
@@ -128,6 +130,8 @@ func parseConfigInput(command string, args []string, output io.Writer) (configIn
|
||||
}
|
||||
var value any = f.Value.String()
|
||||
switch f.Name {
|
||||
case "reporting", "debug":
|
||||
value, _ = strconv.ParseBool(f.Value.String())
|
||||
case "modules":
|
||||
modules, err := config.ParseModulesCSV(f.Value.String())
|
||||
if err != nil {
|
||||
@@ -203,3 +207,16 @@ func configInputError(err error) string {
|
||||
}
|
||||
return strings.Join(messages, "; ")
|
||||
}
|
||||
|
||||
func selectedReportDir(cfg config.Config, outputPath string) (string, error) {
|
||||
if !cfg.Reporting.Enabled {
|
||||
return "", nil
|
||||
}
|
||||
if strings.TrimSpace(outputPath) != "" {
|
||||
return filepath.Dir(outputPath), nil
|
||||
}
|
||||
if strings.TrimSpace(cfg.Reporting.StdoutDir) == "" {
|
||||
return "", fmt.Errorf("report directory is required when reporting is enabled and transcript output is stdout")
|
||||
}
|
||||
return cfg.Reporting.StdoutDir, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user