cli

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2026 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProviderDeepSeek uses DeepSeek API for restructuring.
	ProviderDeepSeek = "deepseek"
	// ProviderOpenAI uses OpenAI API for restructuring.
	ProviderOpenAI = "openai"
)

Restructuring provider constants.

View Source
const (
	EnvOpenAIAPIKey   = "OPENAI_API_KEY"
	EnvDeepSeekAPIKey = "DEEPSEEK_API_KEY"
)

Environment variable names for API keys. #nosec G101 -- these are env var names, not credentials

Variables

View Source
var (
	// ErrAPIKeyMissing indicates OPENAI_API_KEY environment variable is not set.
	ErrAPIKeyMissing = errors.New("OPENAI_API_KEY environment variable not set")

	// ErrDeepSeekKeyMissing indicates DEEPSEEK_API_KEY environment variable is not set.
	ErrDeepSeekKeyMissing = errors.New("DEEPSEEK_API_KEY environment variable not set")

	// ErrInvalidDuration indicates a duration string could not be parsed.
	ErrInvalidDuration = errors.New("invalid duration format")

	// ErrUnsupportedFormat indicates an audio file has an unsupported extension.
	ErrUnsupportedFormat = errors.New("unsupported audio format")

	// ErrFileNotFound indicates the specified input file does not exist.
	ErrFileNotFound = errors.New("file not found")

	// ErrOutputExists indicates the output file already exists.
	ErrOutputExists = errors.New("output file already exists")
)
View Source
var (
	DeepSeekProvider = Provider{/* contains filtered or unexported fields */}
	OpenAIProvider   = Provider{/* contains filtered or unexported fields */}
)

Pre-parsed provider constants for use in code. These avoid parsing overhead and provide compile-time safety.

View Source
var ErrInvalidProvider = errors.New("invalid provider")

ErrInvalidProvider indicates an invalid provider name was specified.

View Source
var ErrUnsupportedProvider = fmt.Errorf("unsupported provider (use %q or %q)", ProviderDeepSeek, ProviderOpenAI)

ErrUnsupportedProvider indicates an unknown provider was passed to the factory. With the Provider type, this error is only reachable if: 1. A zero-value Provider is passed without defaulting 2. The Provider type is extended but the factory is not updated Normal CLI flows default zero providers to DeepSeek before calling the factory.

Functions

func ConfigCmd

func ConfigCmd(env *Env) *cobra.Command

ConfigCmd creates the config command with subcommands. The env parameter provides injectable dependencies for testing.

func LiveCmd

func LiveCmd(env *Env) *cobra.Command

LiveCmd creates the live command (record + transcribe in one step). The env parameter provides injectable dependencies for testing.

func RecordCmd

func RecordCmd(env *Env) *cobra.Command

RecordCmd creates the record command. The env parameter provides injectable dependencies for testing.

func StructureCmd added in v0.1.0

func StructureCmd(env *Env) *cobra.Command

StructureCmd creates the structure command (restructure an existing transcript). The env parameter provides injectable dependencies for testing.

func TranscribeCmd

func TranscribeCmd(env *Env) *cobra.Command

TranscribeCmd creates the transcribe command. The env parameter provides injectable dependencies for testing.

Types

type ChunkerFactory

type ChunkerFactory interface {
	NewSilenceChunker(ffmpegPath string) (audio.Chunker, error)
}

ChunkerFactory creates audio chunkers.

type ConfigLoader

type ConfigLoader interface {
	Load() (config.Config, error)
}

ConfigLoader loads and provides access to configuration.

type Env

type Env struct {
	// I/O and environment
	Stderr io.Writer
	Getenv func(string) string
	Now    func() time.Time

	// Factories for domain objects
	FFmpegResolver      FFmpegResolver
	ConfigLoader        ConfigLoader
	TranscriberFactory  TranscriberFactory
	RestructurerFactory RestructurerFactory
	ChunkerFactory      ChunkerFactory
	RecorderFactory     RecorderFactory
}

Env holds injectable dependencies for CLI commands. This is the central injection point for testing CLI commands in isolation.

All fields have sensible defaults via DefaultEnv(). Tests can override specific fields using the With* options or by creating a custom Env.

Env must not be nil when passed to command functions. Use DefaultEnv() or NewEnv() to create a valid instance.

func DefaultEnv

func DefaultEnv() *Env

DefaultEnv returns an Env with production defaults.

func NewEnv

func NewEnv(opts ...EnvOption) *Env

NewEnv creates an Env with the given options applied to defaults.

type EnvOption

type EnvOption func(*Env)

EnvOption configures an Env.

func WithChunkerFactory

func WithChunkerFactory(f ChunkerFactory) EnvOption

WithChunkerFactory sets the chunker factory.

func WithConfigLoader

func WithConfigLoader(l ConfigLoader) EnvOption

WithConfigLoader sets the config loader.

func WithFFmpegResolver

func WithFFmpegResolver(r FFmpegResolver) EnvOption

WithFFmpegResolver sets the FFmpeg resolver.

func WithGetenv

func WithGetenv(fn func(string) string) EnvOption

WithGetenv sets the environment variable getter.

func WithNow

func WithNow(fn func() time.Time) EnvOption

WithNow sets the time provider.

func WithRecorderFactory

func WithRecorderFactory(f RecorderFactory) EnvOption

WithRecorderFactory sets the recorder factory.

func WithRestructurerFactory

func WithRestructurerFactory(f RestructurerFactory) EnvOption

WithRestructurerFactory sets the restructurer factory.

func WithStderr

func WithStderr(w io.Writer) EnvOption

WithStderr sets the stderr writer.

func WithTranscriberFactory

func WithTranscriberFactory(f TranscriberFactory) EnvOption

WithTranscriberFactory sets the transcriber factory.

type FFmpegResolver

type FFmpegResolver interface {
	Resolve(ctx context.Context) (string, error)
	CheckVersion(ctx context.Context, ffmpegPath string)
}

FFmpegResolver resolves the path to the FFmpeg binary.

type Provider added in v0.3.0

type Provider struct {
	// contains filtered or unexported fields
}

Provider represents a validated LLM provider for restructuring. Zero value is invalid and must not be used. Use ParseProvider to create from user input, or the pre-parsed constants.

func MustParseProvider added in v0.3.0

func MustParseProvider(s string) Provider

MustParseProvider parses a provider name, panicking if invalid. Use only for compile-time constants and tests.

func ParseProvider added in v0.3.0

func ParseProvider(s string) (Provider, error)

ParseProvider validates and parses a provider name string. Returns ErrInvalidProvider if the name is not recognized. Empty string returns an error (unlike Language where empty means auto-detect).

func (Provider) IsDeepSeek added in v0.3.0

func (p Provider) IsDeepSeek() bool

IsDeepSeek returns true if this provider is DeepSeek.

func (Provider) IsOpenAI added in v0.3.0

func (p Provider) IsOpenAI() bool

IsOpenAI returns true if this provider is OpenAI.

func (Provider) IsZero added in v0.3.0

func (p Provider) IsZero() bool

IsZero returns true if this is the zero value (no provider set). Unlike Language.IsZero() which represents valid "auto-detect" mode, Provider.IsZero() indicates an invalid/unset state that must be defaulted before use (typically to DeepSeekProvider).

func (Provider) OrDefault added in v0.3.0

func (p Provider) OrDefault() Provider

OrDefault returns the provider, or DeepSeekProvider if zero. Use this to apply the default provider consistently.

func (Provider) String added in v0.3.0

func (p Provider) String() string

String returns the provider name string. Returns empty string for zero value.

type RecorderFactory

type RecorderFactory interface {
	NewRecorder(ffmpegPath, device string) (audio.Recorder, error)
	NewLoopbackRecorder(ctx context.Context, ffmpegPath string) (audio.Recorder, error)
	NewMixRecorder(ctx context.Context, ffmpegPath, micDevice string) (audio.Recorder, error)
}

RecorderFactory creates audio recorders.

type RestructureOptions added in v0.1.0

type RestructureOptions struct {
	// Template (required): validated template name
	Template template.Name
	// Provider (required): validated LLM provider
	Provider Provider
	// Output language (optional): zero value = English (template's native language)
	OutputLang lang.Language
	// Optional progress callback for long transcripts
	OnProgress func(phase string, current, total int)
}

RestructureOptions configures transcript restructuring.

type RestructurerFactory

type RestructurerFactory interface {
	// NewMapReducer creates a MapReducer configured with the given provider, API key, and options.
	// Provider must be a valid Provider (DeepSeekProvider or OpenAIProvider).
	// This is the primary method for creating restructurers in CLI commands.
	NewMapReducer(provider Provider, apiKey string, opts ...restructure.MapReduceOption) (restructure.MapReducer, error)
}

RestructurerFactory creates restructurers for transcript formatting.

type TranscriberFactory

type TranscriberFactory interface {
	NewTranscriber(apiKey string) transcribe.Transcriber
}

TranscriberFactory creates transcribers for audio-to-text conversion.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL