Documentation
¶
Index ¶
Constants ¶
const (
EnvOutputDir = "TRANSCRIPT_OUTPUT_DIR"
)
Environment variable fallbacks.
const (
KeyOutputDir = "output-dir"
)
Config keys.
Variables ¶
var ( // ErrInvalidSyntax is returned when the config file has invalid syntax. ErrInvalidSyntax = errors.New("invalid config syntax") // ErrInvalidKey is returned when a config key contains invalid characters. ErrInvalidKey = errors.New("invalid config key") // ErrNotWritable is returned when a directory is not writable. ErrNotWritable = errors.New("directory not writable") // ErrNotDirectory is returned when a path is not a directory. ErrNotDirectory = errors.New("path is not a directory") )
Sentinel errors for error handling with errors.Is().
Functions ¶
func EnsureOutputDir ¶
EnsureOutputDir validates a directory path and creates it if it doesn't exist. Returns nil if the directory exists and is writable, or was successfully created. Returns an error describing the problem otherwise.
Note: Tilde expansion is performed via ExpandPath. If expansion fails (e.g., home directory cannot be determined), the path is used as-is, which will likely result in an error from os.Stat or os.MkdirAll.
func ExpandPath ¶
ExpandPath expands ~ or ~/path to the user's home directory. Returns the path unchanged if expansion fails or if it doesn't start with ~.
func Get ¶
Get reads a single value from the config file. Returns empty string if the key doesn't exist.
func ResolveOutputPath ¶
ResolveOutputPath resolves the final output path using the following precedence:
- If output is absolute, use it as-is
- If output is relative and outputDir is set, join them
- If output is empty, use defaultName in outputDir (or cwd if no outputDir)
outputDir can come from config or flag. All paths are cleaned using filepath.Clean to normalize separators and remove redundant elements.
func Save ¶
Save writes a single key=value to the config file. Creates the config directory and file if they don't exist. Preserves existing key=value pairs but discards comments. Returns ErrInvalidKey if the key contains = or newline characters.
WARNING: This function rewrites the entire config file. Any comments (lines starting with #) in the original file will be lost. This is a known limitation of the current implementation.