diff options
author | iximeow <me@iximeow.net> | 2017-10-23 01:19:20 -0700 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2017-10-23 01:19:20 -0700 |
commit | c2608157f343ac16592e626536673b16849382ee (patch) | |
tree | 2d86c2251adb63778123f960487745d9eb4efbdf /src/commands/fav.rs | |
parent | 5f3ebcf73f3df5f9993503b31d97b50f5f2901c0 (diff) |
thingiemapoo grows a real display!
kind of.
add DisplayInfo struct that eventually can be used for rendering to any
particular interface. I care primarily about rendering to a CLI, so.
to support this: many instances of rendering with println!() are moved
to at least be orchestrated by display::paint, which will eventually
become smart enough to handle a reserved area for state notifications
from the client, and buffer input nicely, ....
more code moved over to use TweetId instead of bare strings
because DisplayInfo is currently a member on TwitterCache, any cases of
writing to DisplayInfo also involve writing to TwitterCache, which means
TwitterCache is mut like... everywhere.
Also, invalid TweetId in IdConversions ends up logging, meaning anything
calling that conversion requires a mut TwitterCache, by the above
paragraph.
Diffstat (limited to 'src/commands/fav.rs')
-rw-r--r-- | src/commands/fav.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/commands/fav.rs b/src/commands/fav.rs index 7b9cce6..1cb41e4 100644 --- a/src/commands/fav.rs +++ b/src/commands/fav.rs @@ -5,8 +5,6 @@ use tw::TweetId; use commands::Command; -use std::str::FromStr; - static FAV_TWEET_URL: &str = "https://api.twitter.com/1.1/favorites/create.json"; static UNFAV_TWEET_URL: &str = "https://api.twitter.com/1.1/favorites/destroy.json"; @@ -21,12 +19,12 @@ fn unfav(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) { // let inner_twid = u64::from_str(&line).unwrap(); let maybe_id = TweetId::parse(line.to_owned()); match maybe_id { - Some(twid) => { + Ok(twid) => { let twete = tweeter.retrieve_tweet(&twid).unwrap(); queryer.do_api_post(&format!("{}?id={}", UNFAV_TWEET_URL, twete.id)); } - None => { - println!("Invalid id: {}", line); + Err(e) => { + println!("Invalid id: {}", e); } } } @@ -41,12 +39,12 @@ fn fav(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) { // TODO handle this unwrap let maybe_id = TweetId::parse(line.to_owned()); match maybe_id { - Some(twid) => { + Ok(twid) => { let twete = tweeter.retrieve_tweet(&twid).unwrap(); queryer.do_api_post(&format!("{}?id={}", FAV_TWEET_URL, twete.id)); } - None => { - println!("Invalid id: {}", line); + Err(e) => { + println!("Invalid id: {}", e); } } } |