33 lines
1.0 KiB
Rust
33 lines
1.0 KiB
Rust
|
extern crate stc;
|
||
|
|
||
|
use std::env;
|
||
|
|
||
|
#[macro_use]
|
||
|
extern crate log;
|
||
|
extern crate env_logger;
|
||
|
|
||
|
use stc::searchers::{Searcher, AggregateSearcher};
|
||
|
use stc::searchers::mtg::{MtgCard, MtgSearcher};
|
||
|
use stc::searchers::yugioh::{YugiohCard, YugiohSearcher};
|
||
|
|
||
|
fn main () {
|
||
|
env_logger::init().unwrap();
|
||
|
|
||
|
let term = env::args().nth(1).expect("please supply a search term as argument");
|
||
|
let mut searchers = AggregateSearcher::new();
|
||
|
searchers.add_searcher("mtg", Box::new(MtgSearcher::new()));
|
||
|
searchers.add_searcher("ygo", Box::new(YugiohSearcher::new()));
|
||
|
match searchers.exact_search(&term) {
|
||
|
Some(item) => {
|
||
|
if let Some(card) = item.as_any().downcast_ref::<MtgCard>() {
|
||
|
println!("{:?}", card);
|
||
|
} else if let Some(card) = item.as_any().downcast_ref::<YugiohCard>() {
|
||
|
println!("{:?}", card);
|
||
|
} else {
|
||
|
println!("{}: {}", item.label(), item.url());
|
||
|
}
|
||
|
},
|
||
|
None => println!("not found...")
|
||
|
}
|
||
|
}
|