use crate::app::command::FixtureStateCommand;
use crate::app::runtime_fixture_state::{
    diff_state, export_fixture_state, export_overlay_import, export_save_slice, load_save_slice,
    snapshot_save_state, snapshot_state, summarize_fixture, summarize_save_load, summarize_state,
    validate_fixture,
};

pub(super) fn dispatch_fixture_state(
    command: FixtureStateCommand,
) -> Result<(), Box<dyn std::error::Error>> {
    match command {
        FixtureStateCommand::ValidateFixture { fixture_path } => validate_fixture(&fixture_path),
        FixtureStateCommand::SummarizeFixture { fixture_path } => summarize_fixture(&fixture_path),
        FixtureStateCommand::ExportFixtureState {
            fixture_path,
            output_path,
        } => export_fixture_state(&fixture_path, &output_path),
        FixtureStateCommand::DiffState {
            left_path,
            right_path,
        } => diff_state(&left_path, &right_path),
        FixtureStateCommand::SummarizeState { snapshot_path } => summarize_state(&snapshot_path),
        FixtureStateCommand::SnapshotState {
            input_path,
            output_path,
        } => snapshot_state(&input_path, &output_path),
        FixtureStateCommand::SummarizeSaveLoad { smp_path } => summarize_save_load(&smp_path),
        FixtureStateCommand::LoadSaveSlice { smp_path } => load_save_slice(&smp_path),
        FixtureStateCommand::SnapshotSaveState {
            smp_path,
            output_path,
        } => snapshot_save_state(&smp_path, &output_path),
        FixtureStateCommand::ExportSaveSlice {
            smp_path,
            output_path,
        } => export_save_slice(&smp_path, &output_path),
        FixtureStateCommand::ExportOverlayImport {
            snapshot_path,
            save_slice_path,
            output_path,
        } => export_overlay_import(&snapshot_path, &save_slice_path, &output_path),
    }
}
