aboutsummaryrefslogtreecommitdiff
path: root/src/commands/look_up.rs
diff options
context:
space:
mode:
authorAndy Wortman <ixineeringeverywhere@gmail.com>2017-10-25 04:07:32 -0700
committerAndy Wortman <ixineeringeverywhere@gmail.com>2017-10-25 04:07:32 -0700
commitccccc6e1b2ebd62a35715f71c746f3a3b9c0b97e (patch)
tree8bb44e53dab2a9b5f94284ca0f390061032eb4f1 /src/commands/look_up.rs
parent580f44092358cc260db00ec9871caecac62de361 (diff)
begin removing unwrap()
Diffstat (limited to 'src/commands/look_up.rs')
-rw-r--r--src/commands/look_up.rs17
1 files changed, 13 insertions, 4 deletions
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));
+ }
}
}