Skip to main content

omni_dev/cli/transcript/
format.rs

1//! `clap::ValueEnum` mirror of [`crate::transcript::format::Format`].
2//!
3//! The library [`Format`] intentionally
4//! has no `clap` dependency — that's a hard architectural rule so the
5//! `transcript` library remains reusable by non-CLI consumers. This thin
6//! enum bridges clap's argument parsing to the library type.
7
8use clap::ValueEnum;
9
10use crate::transcript::format::Format;
11
12/// CLI-visible transcript output format.
13#[derive(Clone, Copy, Debug, PartialEq, Eq, ValueEnum)]
14#[value(rename_all = "lowercase")]
15pub enum CliFormat {
16    /// SubRip (`.srt`).
17    Srt,
18    /// WebVTT (`.vtt`).
19    Vtt,
20    /// Plain text — cue text only, one cue per line.
21    Txt,
22    /// JSON — the full transcript struct.
23    Json,
24}
25
26impl From<CliFormat> for Format {
27    fn from(value: CliFormat) -> Self {
28        match value {
29            CliFormat::Srt => Self::Srt,
30            CliFormat::Vtt => Self::Vtt,
31            CliFormat::Txt => Self::Txt,
32            CliFormat::Json => Self::Json,
33        }
34    }
35}
36
37#[cfg(test)]
38mod tests {
39    use super::*;
40
41    #[test]
42    fn each_variant_maps_to_library_format() {
43        assert_eq!(Format::from(CliFormat::Srt), Format::Srt);
44        assert_eq!(Format::from(CliFormat::Vtt), Format::Vtt);
45        assert_eq!(Format::from(CliFormat::Txt), Format::Txt);
46        assert_eq!(Format::from(CliFormat::Json), Format::Json);
47    }
48}