From ccccc6e1b2ebd62a35715f71c746f3a3b9c0b97e Mon Sep 17 00:00:00 2001 From: Andy Wortman Date: Wed, 25 Oct 2017 04:07:32 -0700 Subject: begin removing unwrap() --- src/commands/look_up.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/commands/look_up.rs') diff --git a/src/commands/look_up.rs b/src/commands/look_up.rs index 386fade..701ce2d 100644 --- a/src/commands/look_up.rs +++ b/src/commands/look_up.rs @@ -1,4 +1,6 @@ use tw; +use tw::TweetId; +use display; use ::Queryer; use commands::Command; @@ -25,9 +27,16 @@ pub static LOOK_UP_TWEET: Command = Command { // TODO: make this parse a proper tweet id fn look_up_tweet(line: String, tweeter: &mut tw::TwitterCache, mut queryer: &mut Queryer) { - if let Some(tweet) = tweeter.fetch_tweet(&line, &mut queryer) { - println!("{:?}", tweet); - } else { -// println!("Couldn't retrieve {}", tweetid); + match TweetId::parse(line) { + Ok(twid) => { + if let Some(tweet) = tweeter.fetch_tweet(&twid, &mut queryer).map(|x| x.clone()) { + tweeter.display_info.recv(display::Infos::Tweet(twid)); + } else { + tweeter.display_info.status(format!("Couldn't retrieve {:?}", twid)); + } + }, + Err(e) => { + tweeter.display_info.status(format!("Invalid id {:?}", e)); + } } } -- cgit v1.1