aboutsummaryrefslogtreecommitdiff
path: root/commands/show_cache.rs
blob: 3c31697733411f33a970590171a2c4952540a3ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use tw;
use ::Queryer;

use commands::Command;

pub static SHOW_CACHE: Command = Command {
    keyword: "show_cache",
    params: 0,
    exec: show_cache
};

fn show_cache(line: String, tweeter: &mut tw::TwitterCache, mut queryer: &mut Queryer) {
    println!("----* USERS *----");
    for (uid, user) in &tweeter.users {
        println!("User: {} -> {:?}", uid, user);
    }
    println!("----* TWEETS *----");
    for (tid, tweet) in &tweeter.tweets {
        println!("Tweet: {} -> {:?}", tid, tweet);
    }
    println!("----* FOLLOWERS *----");
    for uid in &tweeter.followers.clone() {
        let user_res = tweeter.fetch_user(uid, &mut queryer);
        match user_res {
            Some(user) => {
                println!("Follower: {} - {:?}", uid, user);
            }
            None => { println!("  ..."); }
        }
    }
}