From e4925f0311574cd954909695bb587902179f8680 Mon Sep 17 00:00:00 2001 From: Andy Wortman Date: Sat, 25 Nov 2017 18:39:04 -0800 Subject: extract DisplayInfo from TwitterCache what a mess... threading this through to any point where printing happens is upsetting. probably should be a global mutable behind accessors. --- src/commands/show_cache.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/commands/show_cache.rs') diff --git a/src/commands/show_cache.rs b/src/commands/show_cache.rs index 6dda8dc..2b810d7 100644 --- a/src/commands/show_cache.rs +++ b/src/commands/show_cache.rs @@ -1,3 +1,4 @@ +use display::DisplayInfo; use tw; use ::Queryer; @@ -11,24 +12,24 @@ pub static SHOW_CACHE: Command = Command { help_str: "Dump all cached info. Probably a bad idea." }; -fn show_cache(_line: String, tweeter: &mut tw::TwitterCache, mut queryer: &mut Queryer) { +fn show_cache(_line: String, tweeter: &mut tw::TwitterCache, mut queryer: &mut Queryer, display_info: &mut DisplayInfo) { /* - tweeter.display_info.status("----* USERS *----".to_owned()); + display_info.status("----* USERS *----".to_owned()); for (uid, user) in &tweeter.users { - tweeter.display_info.status(format!("User: {} -> {:?}", uid, user)); + display_info.status(format!("User: {} -> {:?}", uid, user)); } - tweeter.display_info.status("----* TWEETS *----".to_owned()); + display_info.status("----* TWEETS *----".to_owned()); for (tid, tweet) in &tweeter.tweets { - tweeter.display_info.status(format!("Tweet: {} -> {:?}", tid, tweet)); + display_info.status(format!("Tweet: {} -> {:?}", tid, tweet)); } - tweeter.display_info.status("----* FOLLOWERS *----".to_owned()); + display_info.status("----* FOLLOWERS *----".to_owned()); for uid in &tweeter.followers.clone() { let user_res = tweeter.fetch_user(uid, &mut queryer).map(|x| x.clone()); match user_res { Some(user) => { - tweeter.display_info.status(format!("Follower: {} - {:?}", uid, user)); + display_info.status(format!("Follower: {} - {:?}", uid, user)); } - None => { tweeter.display_info.status(" ...".to_owned()); } + None => { display_info.status(" ...".to_owned()); } } } */ -- cgit v1.1