arib-cli 0.3.0

Reads the signalling of ARIB broadcasts, as an example of the arib crate
//! The subcommands.

mod data;
mod events;
mod logos;
mod services;
mod status;
mod subtitles;

use clap::{Parser, Subcommand};

#[derive(Clone, Debug, Parser)]
#[command(version, about)]
pub struct Cli {
    /// Shows the details of the events: their genres, whether they are scrambled, and the items
    /// of their detailed description.
    #[arg(short, long, global = true)]
    verbose: bool,

    #[command(subcommand)]
    command: Command,
}

#[derive(Clone, Debug, Subcommand)]
enum Command {
    Status(status::Options),
    Services(services::Options),
    Events(events::Options),
    Logos(logos::Options),
    Data(data::Options),
    Subtitles(subtitles::Options),
}

impl Cli {
    pub fn run(&self) -> anyhow::Result<()> {
        match &self.command {
            Command::Status(options) => status::run(options, self.verbose),
            Command::Services(options) => services::run(options),
            Command::Events(options) => events::run(options, self.verbose),
            Command::Logos(options) => logos::run(options),
            Command::Data(options) => data::run(options),
            Command::Subtitles(options) => subtitles::run(options),
        }
    }
}