Extract shared CLI flag wiring helpers
This commit is contained in:
31
internal/cli/flags.go
Normal file
31
internal/cli/flags.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"gitea.maximumdirect.net/eric/seriatim/internal/config"
|
||||
)
|
||||
|
||||
func addOutputFileFlag(cmd *cobra.Command, target *string) {
|
||||
cmd.Flags().StringVar(target, "output-file", "", "output transcript JSON file")
|
||||
}
|
||||
|
||||
func addReportFileFlag(cmd *cobra.Command, target *string) {
|
||||
cmd.Flags().StringVar(target, "report-file", "", "optional report JSON file")
|
||||
}
|
||||
|
||||
func addOutputModulesFlag(cmd *cobra.Command, target *string) {
|
||||
cmd.Flags().StringVar(target, "output-modules", config.DefaultOutputModules, "comma-separated output modules")
|
||||
}
|
||||
|
||||
func addMergeOutputSchemaFlag(cmd *cobra.Command, target *string) {
|
||||
cmd.Flags().StringVar(target, "output-schema", config.DefaultOutputSchema, "output JSON schema: seriatim-minimal, seriatim-intermediate (default), or seriatim-full")
|
||||
}
|
||||
|
||||
func addNormalizeOutputSchemaFlag(cmd *cobra.Command, target *string) {
|
||||
cmd.Flags().StringVar(target, "output-schema", config.DefaultOutputSchema, "output JSON schema: seriatim-minimal, seriatim-intermediate, or seriatim-full")
|
||||
}
|
||||
|
||||
func addTrimOutputSchemaFlag(cmd *cobra.Command, target *string) {
|
||||
cmd.Flags().StringVar(target, "output-schema", "", "optional output JSON schema override: seriatim-minimal, seriatim-intermediate, or seriatim-full")
|
||||
}
|
||||
@@ -31,13 +31,13 @@ func newMergeCommand() *cobra.Command {
|
||||
|
||||
flags := cmd.Flags()
|
||||
flags.StringArrayVar(&opts.InputFiles, "input-file", nil, "input transcript file; may be repeated")
|
||||
flags.StringVar(&opts.OutputFile, "output-file", "", "output transcript JSON file")
|
||||
flags.StringVar(&opts.ReportFile, "report-file", "", "optional report JSON file")
|
||||
addOutputFileFlag(cmd, &opts.OutputFile)
|
||||
addReportFileFlag(cmd, &opts.ReportFile)
|
||||
flags.StringVar(&opts.SpeakersFile, "speakers", "", "speaker map file")
|
||||
flags.StringVar(&opts.AutocorrectFile, "autocorrect", "", "autocorrect rules file")
|
||||
flags.StringVar(&opts.InputReader, "input-reader", config.DefaultInputReader, "input reader module")
|
||||
flags.StringVar(&opts.OutputModules, "output-modules", config.DefaultOutputModules, "comma-separated output modules")
|
||||
flags.StringVar(&opts.OutputSchema, "output-schema", config.DefaultOutputSchema, "output JSON schema: seriatim-minimal, seriatim-intermediate (default), or seriatim-full")
|
||||
addOutputModulesFlag(cmd, &opts.OutputModules)
|
||||
addMergeOutputSchemaFlag(cmd, &opts.OutputSchema)
|
||||
flags.StringVar(&opts.PreprocessingModules, "preprocessing-modules", config.DefaultPreprocessingModules, "comma-separated preprocessing modules")
|
||||
flags.StringVar(&opts.PostprocessingModules, "postprocessing-modules", config.DefaultPostprocessingModules, "comma-separated postprocessing modules")
|
||||
flags.StringVar(&opts.CoalesceGap, "coalesce-gap", config.DefaultCoalesceGapValue, "maximum same-speaker gap in seconds for coalesce")
|
||||
|
||||
@@ -30,10 +30,10 @@ func newNormalizeCommand() *cobra.Command {
|
||||
|
||||
flags := cmd.Flags()
|
||||
flags.StringVar(&opts.InputFile, "input-file", "", "input transcript JSON file")
|
||||
flags.StringVar(&opts.OutputFile, "output-file", "", "output transcript JSON file")
|
||||
flags.StringVar(&opts.ReportFile, "report-file", "", "optional report JSON file")
|
||||
flags.StringVar(&opts.OutputSchema, "output-schema", config.DefaultOutputSchema, "output JSON schema: seriatim-minimal, seriatim-intermediate, or seriatim-full")
|
||||
flags.StringVar(&opts.OutputModules, "output-modules", config.DefaultOutputModules, "comma-separated output modules")
|
||||
addOutputFileFlag(cmd, &opts.OutputFile)
|
||||
addReportFileFlag(cmd, &opts.ReportFile)
|
||||
addNormalizeOutputSchemaFlag(cmd, &opts.OutputSchema)
|
||||
addOutputModulesFlag(cmd, &opts.OutputModules)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -30,11 +30,11 @@ func newTrimCommand() *cobra.Command {
|
||||
|
||||
flags := cmd.Flags()
|
||||
flags.StringVar(&opts.InputFile, "input-file", "", "input seriatim transcript artifact JSON file")
|
||||
flags.StringVar(&opts.OutputFile, "output-file", "", "output transcript JSON file")
|
||||
flags.StringVar(&opts.ReportFile, "report-file", "", "optional report JSON file")
|
||||
addOutputFileFlag(cmd, &opts.OutputFile)
|
||||
addReportFileFlag(cmd, &opts.ReportFile)
|
||||
flags.StringVar(&opts.Keep, "keep", "", "segment ID selector to keep (for example: 1-10,15)")
|
||||
flags.StringVar(&opts.Remove, "remove", "", "segment ID selector to remove (for example: 1-10,15)")
|
||||
flags.StringVar(&opts.OutputSchema, "output-schema", "", "optional output JSON schema override: seriatim-minimal, seriatim-intermediate, or seriatim-full")
|
||||
addTrimOutputSchemaFlag(cmd, &opts.OutputSchema)
|
||||
flags.BoolVar(&opts.AllowEmpty, "allow-empty", false, "allow trimming to an empty transcript")
|
||||
|
||||
return cmd
|
||||
|
||||
Reference in New Issue
Block a user