use crate::commands::{Cli, Result};
use clap::{Parser, Subcommand};

mod show_client;
mod show_company;
mod show_invoice;
mod show_job;
mod show_work;
mod show_worker;

use show_client::ShowClient;
use show_company::ShowCompany;
use show_invoice::ShowInvoice;
use show_job::ShowJob;
use show_work::ShowWork;
use show_worker::ShowWorker;

/// Show database entity
#[derive(Parser)]
pub(crate) struct Show {
    #[command(subcommand)]
    pub(crate) command: ShowCommand,
}

#[derive(Subcommand)]
pub(crate) enum ShowCommand {
    /// Show company information
    Company(ShowCompany),
    /// Show client
    Client(ShowClient),
    /// Show workr
    Worker(ShowWorker),
    /// Show work
    Work(ShowWork),
    /// Show job
    Job(ShowJob),
    /// Show invoice
    Invoice(ShowInvoice),
}

impl Show {
    pub(crate) fn run(&self, cli: &Cli) -> Result<()> {
        match &self.command {
            ShowCommand::Company(show) => show.run(cli),
            ShowCommand::Client(show) => show.run(cli),
            ShowCommand::Worker(show) => show.run(cli),
            ShowCommand::Work(show) => show.run(cli),
            ShowCommand::Job(show) => show.run(cli),
            ShowCommand::Invoice(show) => show.run(cli),
        }
    }
}
