use super::{Command, FinanceCommand, usage_error};

pub(super) fn parse_finance_command(
    args: &[String],
) -> Result<Command, Box<dyn std::error::Error>> {
    match args {
        [subcommand, snapshot_path] if subcommand == "eval" => {
            Ok(Command::Finance(FinanceCommand::Eval {
                snapshot_path: snapshot_path.into(),
            }))
        }
        [subcommand, left_path, right_path] if subcommand == "diff" => {
            Ok(Command::Finance(FinanceCommand::Diff {
                left_path: left_path.into(),
                right_path: right_path.into(),
            }))
        }
        _ => usage_error(),
    }
}
