use rhai::{Array, Engine}; use crate::{api::models::{OrderServerProduct, AuctionServerProduct, AuctionTransaction, ServerAddonProduct, ServerAddonTransaction, Server, SshKey}}; mod servers_table; mod ssh_keys_table; mod server_ordering_table; // This will be called when we print(...) or pretty_print() an Array (with Dynamic values) pub fn pretty_print_dispatch(array: Array) { if array.is_empty() { println!(""); return; } let first = &array[0]; if first.is::() { println!("Yeah first is server!"); servers_table::pretty_print_servers(array); } else if first.is::() { ssh_keys_table::pretty_print_ssh_keys(array); } else if first.is::() { server_ordering_table::pretty_print_server_products(array); } else if first.is::() { server_ordering_table::pretty_print_auction_server_products(array); } else if first.is::() { server_ordering_table::pretty_print_auction_transactions(array); } else if first.is::() { server_ordering_table::pretty_print_server_addon_products(array); } else if first.is::() { server_ordering_table::pretty_print_server_addon_transactions(array); } else { // Generic fallback for other types for item in array { println!("{}", item.to_string()); } } } pub fn register(engine: &mut Engine) { engine.register_fn("pretty_print", pretty_print_dispatch); }