use crate::app::command::InspectCommand;
use crate::app::runtime_compare::inspect_candidate_table;
use crate::app::runtime_inspect::{
    export_profile_block, extract_pk4_entry, inspect_building_type_sources, inspect_campaign_exe,
    inspect_cargo_economy_sources, inspect_cargo_price_selector, inspect_cargo_production_selector,
    inspect_cargo_skins, inspect_cargo_types, inspect_compact_event_dispatch_cluster,
    inspect_compact_event_dispatch_cluster_counts, inspect_infrastructure_asset_trace,
    inspect_map_title_hints, inspect_periodic_company_service_trace, inspect_pk4,
    inspect_placed_structure_dynamic_side_buffer, inspect_region_service_trace,
    inspect_save_company_chairman, inspect_save_placed_structure_triplets,
    inspect_save_region_queued_notice_records, inspect_smp, inspect_unclassified_save_collections,
    inspect_win,
};

pub(super) fn dispatch_inspect(command: InspectCommand) -> Result<(), Box<dyn std::error::Error>> {
    match command {
        InspectCommand::InspectSmp { smp_path } => inspect_smp(&smp_path),
        InspectCommand::InspectCandidateTable { smp_path } => inspect_candidate_table(&smp_path),
        InspectCommand::InspectCompactEventDispatchCluster { root_path } => {
            inspect_compact_event_dispatch_cluster(&root_path)
        }
        InspectCommand::InspectCompactEventDispatchClusterCounts { root_path } => {
            inspect_compact_event_dispatch_cluster_counts(&root_path)
        }
        InspectCommand::InspectMapTitleHints { root_path } => inspect_map_title_hints(&root_path),
        InspectCommand::InspectSaveCompanyChairman { smp_path } => {
            inspect_save_company_chairman(&smp_path)
        }
        InspectCommand::InspectSavePlacedStructureTriplets { smp_path } => {
            inspect_save_placed_structure_triplets(&smp_path)
        }
        InspectCommand::InspectPeriodicCompanyServiceTrace { smp_path } => {
            inspect_periodic_company_service_trace(&smp_path)
        }
        InspectCommand::InspectRegionServiceTrace { smp_path } => {
            inspect_region_service_trace(&smp_path)
        }
        InspectCommand::InspectInfrastructureAssetTrace { smp_path } => {
            inspect_infrastructure_asset_trace(&smp_path)
        }
        InspectCommand::InspectSaveRegionQueuedNoticeRecords { smp_path } => {
            inspect_save_region_queued_notice_records(&smp_path)
        }
        InspectCommand::InspectPlacedStructureDynamicSideBuffer { smp_path } => {
            inspect_placed_structure_dynamic_side_buffer(&smp_path)
        }
        InspectCommand::InspectUnclassifiedSaveCollections { smp_path } => {
            inspect_unclassified_save_collections(&smp_path)
        }
        InspectCommand::InspectPk4 { pk4_path } => inspect_pk4(&pk4_path),
        InspectCommand::InspectCargoTypes { cargo_types_dir } => {
            inspect_cargo_types(&cargo_types_dir)
        }
        InspectCommand::InspectBuildingTypeSources {
            building_types_dir,
            bindings_path,
        } => inspect_building_type_sources(&building_types_dir, bindings_path.as_deref()),
        InspectCommand::InspectCargoSkins {
            cargo_skin_pk4_path,
        } => inspect_cargo_skins(&cargo_skin_pk4_path),
        InspectCommand::InspectCargoEconomySources {
            cargo_types_dir,
            cargo_skin_pk4_path,
        } => inspect_cargo_economy_sources(&cargo_types_dir, &cargo_skin_pk4_path),
        InspectCommand::InspectCargoProductionSelector {
            cargo_types_dir,
            cargo_skin_pk4_path,
        } => inspect_cargo_production_selector(&cargo_types_dir, &cargo_skin_pk4_path),
        InspectCommand::InspectCargoPriceSelector {
            cargo_types_dir,
            cargo_skin_pk4_path,
        } => inspect_cargo_price_selector(&cargo_types_dir, &cargo_skin_pk4_path),
        InspectCommand::InspectWin { win_path } => inspect_win(&win_path),
        InspectCommand::ExtractPk4Entry {
            pk4_path,
            entry_name,
            output_path,
        } => extract_pk4_entry(&pk4_path, &entry_name, &output_path),
        InspectCommand::InspectCampaignExe { exe_path } => inspect_campaign_exe(&exe_path),
        InspectCommand::ExportProfileBlock {
            smp_path,
            output_path,
        } => export_profile_block(&smp_path, &output_path),
    }
}
