cli

package
v0.1.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 ErrUnsupportedProvider = fmt.Errorf("unsupported provider (use %q or %q)", ProviderDeepSeek, ProviderOpenAI)

ErrUnsupportedProvider indicates an invalid provider was specified.

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 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 name (required): brainstorm, meeting, lecture, notes
	Template string
	// LLM provider: "deepseek" (default) or "openai"
	Provider string
	// Output language (optional): ISO 639-1 code, empty = English
	OutputLang string
	// 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 ProviderDeepSeek or ProviderOpenAI.
	// This is the primary method for creating restructurers in CLI commands.
	NewMapReducer(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