use super::super::{ScanCommand, usage_error};

pub(super) fn parse_scan_command(
    args: &[String],
) -> Result<ScanCommand, Box<dyn std::error::Error>> {
    match args {
        [subcommand, root_path] if subcommand == "scan-candidate-table-headers" => {
            Ok(ScanCommand::ScanCandidateTableHeaders {
                root_path: root_path.into(),
            })
        }
        [subcommand, root_path] if subcommand == "scan-candidate-table-named-runs" => {
            Ok(ScanCommand::ScanCandidateTableNamedRuns {
                root_path: root_path.into(),
            })
        }
        [subcommand, root_path] if subcommand == "scan-special-conditions" => {
            Ok(ScanCommand::ScanSpecialConditions {
                root_path: root_path.into(),
            })
        }
        [subcommand, root_path] if subcommand == "scan-aligned-runtime-rule-band" => {
            Ok(ScanCommand::ScanAlignedRuntimeRuleBand {
                root_path: root_path.into(),
            })
        }
        [subcommand, root_path] if subcommand == "scan-post-special-conditions-scalars" => {
            Ok(ScanCommand::ScanPostSpecialConditionsScalars {
                root_path: root_path.into(),
            })
        }
        [subcommand, root_path] if subcommand == "scan-post-special-conditions-tail" => {
            Ok(ScanCommand::ScanPostSpecialConditionsTail {
                root_path: root_path.into(),
            })
        }
        [subcommand, root_path] if subcommand == "scan-recipe-book-lines" => {
            Ok(ScanCommand::ScanRecipeBookLines {
                root_path: root_path.into(),
            })
        }
        _ => usage_error(),
    }
}
