Skip to main content

omni_dev/cli/transcript/
mod.rs

1//! Transcript and caption fetching from media platforms.
2//!
3//! Provider-namespaced: each source (YouTube today; Vimeo, podcast feeds, …
4//! later) lives under its own subcommand so per-source argument shapes and
5//! help text stay clean.
6
7pub mod format;
8pub mod youtube;
9
10use anyhow::Result;
11use clap::{Parser, Subcommand};
12
13/// Transcript and caption fetching from media platforms.
14#[derive(Parser)]
15pub struct TranscriptCommand {
16    /// The transcript subcommand to execute.
17    #[command(subcommand)]
18    pub command: TranscriptSubcommands,
19}
20
21/// Transcript subcommands, one per media platform.
22#[derive(Subcommand)]
23pub enum TranscriptSubcommands {
24    /// YouTube: fetch captions, list available languages, and inspect video metadata.
25    Youtube(youtube::YoutubeCommand),
26}
27
28impl TranscriptCommand {
29    /// Dispatches to the selected provider.
30    pub async fn execute(self) -> Result<()> {
31        match self.command {
32            TranscriptSubcommands::Youtube(cmd) => cmd.execute().await,
33        }
34    }
35}
36
37#[cfg(test)]
38mod tests {
39    use super::*;
40
41    #[test]
42    fn transcript_subcommands_youtube_variant() {
43        let cmd = TranscriptCommand {
44            command: TranscriptSubcommands::Youtube(youtube::YoutubeCommand {
45                command: youtube::YoutubeSubcommands::Info(youtube::info::InfoCommand {
46                    url: "https://youtu.be/dQw4w9WgXcQ".to_string(),
47                    output: youtube::info::InfoOutput::Table,
48                }),
49            }),
50        };
51        assert!(matches!(cmd.command, TranscriptSubcommands::Youtube(_)));
52    }
53}