From 9951dc9af6ab148b150425c9ef6bd853cccf6594 Mon Sep 17 00:00:00 2001 From: Wasin Thonkaew Date: Sat, 11 Jul 2015 12:34:56 +0700 Subject: [PATCH] Add ability to show conversation (in reply to) for a tweet whenever execute 'status' command. Showing conversation tweets adhere to the options sending in to the 'status' command. It will show all tweets in the upper level from the tweet supplied to 'status' command. --- lib/t/cli.rb | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/t/cli.rb b/lib/t/cli.rb index 66e6158e..26f2a7fa 100644 --- a/lib/t/cli.rb +++ b/lib/t/cli.rb @@ -745,8 +745,34 @@ def status(status_id) # rubocop:disable CyclomaticComplexity array << ['Location', location] unless location.nil? print_table(array) end - end + # showing information about conversation + if status.in_reply_to_status_id? + # print new line preparing for the thread tweet + print "\n"; + print "In reply to ...\n\n" + + # create an array in order to supply it to print_tweets + statusArray = Array.new + + # if this tweet is a reply to the upper-in-level tweet, then also show that information out too + while status.in_reply_to_status_id?do + # get tweet, use the same options to get tweet supplied as parameter to this def + status = client.status(status.in_reply_to_status_id.to_i, opts) + + # add status to array + statusArray.push(status) + end + + # if array is not empty then print tweets out with respect to the options sending in + unless statusArray.empty? + # print tweet + # adhere to options sending in + print_tweets(statusArray) + end + end + end + desc 'timeline [USER]', "Returns the #{DEFAULT_NUM_RESULTS} most recent Tweets posted by a user." method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.' method_option 'decode_uris', aliases: '-d', type: :boolean, desc: 'Decodes t.co URLs into their original form.'