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/follow.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/commands/follow.rs') diff --git a/src/commands/follow.rs b/src/commands/follow.rs index 6e29788..bc767d5 100644 --- a/src/commands/follow.rs +++ b/src/commands/follow.rs @@ -1,3 +1,4 @@ +use display::DisplayInfo; use tw; use ::Queryer; @@ -14,7 +15,7 @@ pub static UNFOLLOW: Command = Command { help_str: "Unfollow . No @ prefix in !" }; -fn unfl(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) { +fn unfl(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer, display_info: &mut DisplayInfo) { let screen_name = line.trim(); let result = match tweeter.current_profile() { Some(user_profile) => { @@ -24,7 +25,7 @@ fn unfl(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) { }; match result { Ok(_resp) => (), - Err(e) => tweeter.display_info.status(format!("unfl request error: {}", e)) + Err(e) => display_info.status(format!("unfl request error: {}", e)) } } @@ -36,11 +37,11 @@ pub static FOLLOW: Command = Command { help_str: "Follow . No @ prefix in !" }; -fn fl(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) { +fn fl(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer, display_info: &mut DisplayInfo) { let screen_name = line.trim(); match tweeter.current_profile().map(|profile| profile.to_owned()) { Some(user_profile) => { - tweeter.display_info.status( + display_info.status( format!( "fl resp: {:?}", queryer.do_api_post( @@ -51,6 +52,6 @@ fn fl(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) { ) ) }, - None => tweeter.display_info.status("No logged in user to follow from".to_owned()) + None => display_info.status("No logged in user to follow from".to_owned()) }; } -- cgit v1.1