t 2.2.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.md +2 -2
- data/bin/t +2 -2
- data/lib/t/cli.rb +211 -129
- data/lib/t/delete.rb +6 -6
- data/lib/t/list.rb +16 -15
- data/lib/t/printable.rb +11 -11
- data/lib/t/rcfile.rb +1 -1
- data/lib/t/requestable.rb +1 -1
- data/lib/t/search.rb +35 -28
- data/lib/t/set.rb +1 -1
- data/lib/t/stream.rb +15 -15
- data/lib/t/utils.rb +7 -3
- data/lib/t/version.rb +2 -2
- data/spec/cli_spec.rb +742 -206
- data/spec/delete_spec.rb +3 -3
- data/spec/helper.rb +1 -1
- data/t.gemspec +1 -1
- metadata +5 -6
- metadata.gz.sig +0 -0
data/lib/t/delete.rb
CHANGED
@@ -17,7 +17,7 @@ module T
|
|
17
17
|
end
|
18
18
|
|
19
19
|
desc 'block USER [USER...]', 'Unblock users.'
|
20
|
-
method_option 'id', :aliases => '-i', :type => :boolean, :
|
20
|
+
method_option 'id', :aliases => '-i', :type => :boolean, :desc => 'Specify input as Twitter user IDs instead of screen names.'
|
21
21
|
method_option 'force', :aliases => '-f', :type => :boolean, :default => false
|
22
22
|
def block(user, *users)
|
23
23
|
unblocked_users, number = fetch_users(users.unshift(user), options) do |users_to_unblock|
|
@@ -25,7 +25,7 @@ module T
|
|
25
25
|
end
|
26
26
|
say "@#{@rcfile.active_profile[0]} unblocked #{pluralize(number, 'user')}."
|
27
27
|
say
|
28
|
-
say "Run `#{File.basename($PROGRAM_NAME)} block #{unblocked_users.
|
28
|
+
say "Run `#{File.basename($PROGRAM_NAME)} block #{unblocked_users.collect { |unblocked_user| "@#{unblocked_user.screen_name}" }.join(' ')}` to block."
|
29
29
|
end
|
30
30
|
|
31
31
|
desc 'dm [DIRECT_MESSAGE_ID] [DIRECT_MESSAGE_ID...]', 'Delete the last Direct Message sent.'
|
@@ -33,7 +33,7 @@ module T
|
|
33
33
|
def dm(direct_message_id, *direct_message_ids)
|
34
34
|
direct_message_ids.unshift(direct_message_id)
|
35
35
|
require 't/core_ext/string'
|
36
|
-
direct_message_ids.
|
36
|
+
direct_message_ids.collect!(&:to_i)
|
37
37
|
if options['force']
|
38
38
|
direct_messages = client.destroy_direct_message(direct_message_ids)
|
39
39
|
direct_messages.each do |direct_message|
|
@@ -55,7 +55,7 @@ module T
|
|
55
55
|
def favorite(status_id, *status_ids)
|
56
56
|
status_ids.unshift(status_id)
|
57
57
|
require 't/core_ext/string'
|
58
|
-
status_ids.
|
58
|
+
status_ids.collect!(&:to_i)
|
59
59
|
if options['force']
|
60
60
|
tweets = client.unfavorite(status_ids)
|
61
61
|
tweets.each do |status|
|
@@ -74,7 +74,7 @@ module T
|
|
74
74
|
|
75
75
|
desc 'list LIST', 'Delete a list.'
|
76
76
|
method_option 'force', :aliases => '-f', :type => :boolean, :default => false
|
77
|
-
method_option 'id', :aliases => '-i', :type => :boolean, :
|
77
|
+
method_option 'id', :aliases => '-i', :type => :boolean, :desc => 'Specify list via ID instead of slug.'
|
78
78
|
def list(list)
|
79
79
|
if options['id']
|
80
80
|
require 't/core_ext/string'
|
@@ -93,7 +93,7 @@ module T
|
|
93
93
|
def status(status_id, *status_ids)
|
94
94
|
status_ids.unshift(status_id)
|
95
95
|
require 't/core_ext/string'
|
96
|
-
status_ids.
|
96
|
+
status_ids.collect!(&:to_i)
|
97
97
|
if options['force']
|
98
98
|
tweets = client.destroy_status(status_ids, :trim_user => true)
|
99
99
|
tweets.each do |status|
|
data/lib/t/list.rb
CHANGED
@@ -25,7 +25,7 @@ module T
|
|
25
25
|
end
|
26
26
|
|
27
27
|
desc 'add LIST USER [USER...]', 'Add members to a list.'
|
28
|
-
method_option 'id', :aliases => '-i', :type => :boolean, :
|
28
|
+
method_option 'id', :aliases => '-i', :type => :boolean, :desc => 'Specify input as Twitter user IDs instead of screen names.'
|
29
29
|
def add(list, user, *users)
|
30
30
|
added_users, number = fetch_users(users.unshift(user), options) do |users_to_add|
|
31
31
|
client.add_list_members(list, users_to_add)
|
@@ -36,7 +36,7 @@ module T
|
|
36
36
|
if options['id']
|
37
37
|
say "Run `#{File.basename($PROGRAM_NAME)} list remove --id #{list} #{added_users.join(' ')}` to undo."
|
38
38
|
else
|
39
|
-
say "Run `#{File.basename($PROGRAM_NAME)} list remove #{list} #{added_users.
|
39
|
+
say "Run `#{File.basename($PROGRAM_NAME)} list remove #{list} #{added_users.collect { |added_user| "@#{added_user}" }.join(' ')}` to undo."
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -50,7 +50,7 @@ module T
|
|
50
50
|
end
|
51
51
|
|
52
52
|
desc 'information [USER/]LIST', 'Retrieves detailed information about a Twitter list.'
|
53
|
-
method_option 'csv', :aliases => '-c', :type => :boolean, :
|
53
|
+
method_option 'csv', :aliases => '-c', :type => :boolean, :desc => 'Output in CSV format.'
|
54
54
|
def information(list)
|
55
55
|
owner, list = extract_owner(list, options)
|
56
56
|
list = client.list(owner, list)
|
@@ -76,12 +76,12 @@ module T
|
|
76
76
|
map %w[details] => :information
|
77
77
|
|
78
78
|
desc 'members [USER/]LIST', 'Returns the members of a Twitter list.'
|
79
|
-
method_option 'csv', :aliases => '-c', :type => :boolean, :
|
80
|
-
method_option 'id', :aliases => '-i', :type => :boolean, :
|
81
|
-
method_option 'long', :aliases => '-l', :type => :boolean, :
|
82
|
-
method_option 'reverse', :aliases => '-r', :type => :boolean, :
|
79
|
+
method_option 'csv', :aliases => '-c', :type => :boolean, :desc => 'Output in CSV format.'
|
80
|
+
method_option 'id', :aliases => '-i', :type => :boolean, :desc => 'Specify user via ID instead of screen name.'
|
81
|
+
method_option 'long', :aliases => '-l', :type => :boolean, :desc => 'Output in long format.'
|
82
|
+
method_option 'reverse', :aliases => '-r', :type => :boolean, :desc => 'Reverse the order of the sort.'
|
83
83
|
method_option 'sort', :aliases => '-s', :type => :string, :enum => %w[favorites followers friends listed screen_name since tweets tweeted], :default => 'screen_name', :desc => 'Specify the order of the results.', :banner => 'ORDER'
|
84
|
-
method_option 'unsorted', :aliases => '-u', :type => :boolean, :
|
84
|
+
method_option 'unsorted', :aliases => '-u', :type => :boolean, :desc => 'Output is not sorted.'
|
85
85
|
def members(list)
|
86
86
|
owner, list = extract_owner(list, options)
|
87
87
|
users = client.list_members(owner, list).to_a
|
@@ -89,7 +89,7 @@ module T
|
|
89
89
|
end
|
90
90
|
|
91
91
|
desc 'remove LIST USER [USER...]', 'Remove members from a list.'
|
92
|
-
method_option 'id', :aliases => '-i', :type => :boolean, :
|
92
|
+
method_option 'id', :aliases => '-i', :type => :boolean, :desc => 'Specify input as Twitter user IDs instead of screen names.'
|
93
93
|
def remove(list, user, *users)
|
94
94
|
removed_users, number = fetch_users(users.unshift(user), options) do |users_to_remove|
|
95
95
|
client.remove_list_members(list, users_to_remove)
|
@@ -100,17 +100,18 @@ module T
|
|
100
100
|
if options['id']
|
101
101
|
say "Run `#{File.basename($PROGRAM_NAME)} list add --id #{list} #{removed_users.join(' ')}` to undo."
|
102
102
|
else
|
103
|
-
say "Run `#{File.basename($PROGRAM_NAME)} list add #{list} #{removed_users.
|
103
|
+
say "Run `#{File.basename($PROGRAM_NAME)} list add #{list} #{removed_users.collect { |removed_user| "@#{removed_user}" }.join(' ')}` to undo."
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
107
|
desc 'timeline [USER/]LIST', 'Show tweet timeline for members of the specified list.'
|
108
|
-
method_option 'csv', :aliases => '-c', :type => :boolean, :
|
109
|
-
method_option 'decode_uris', :aliases => '-d', :type => :boolean, :
|
110
|
-
method_option 'id', :aliases => '-i', :type => :boolean, :
|
111
|
-
method_option 'long', :aliases => '-l', :type => :boolean, :
|
108
|
+
method_option 'csv', :aliases => '-c', :type => :boolean, :desc => 'Output in CSV format.'
|
109
|
+
method_option 'decode_uris', :aliases => '-d', :type => :boolean, :desc => 'Decodes t.co URLs into their original form.'
|
110
|
+
method_option 'id', :aliases => '-i', :type => :boolean, :desc => 'Specify user via ID instead of screen name.'
|
111
|
+
method_option 'long', :aliases => '-l', :type => :boolean, :desc => 'Output in long format.'
|
112
112
|
method_option 'number', :aliases => '-n', :type => :numeric, :default => DEFAULT_NUM_RESULTS, :desc => 'Limit the number of results.'
|
113
|
-
method_option '
|
113
|
+
method_option 'relative_dates', :aliases => '-a', :type => :boolean, :desc => 'Show relative dates.'
|
114
|
+
method_option 'reverse', :aliases => '-r', :type => :boolean, :desc => 'Reverse the order of the sort.'
|
114
115
|
def timeline(list)
|
115
116
|
owner, list = extract_owner(list, options)
|
116
117
|
count = options['number'] || DEFAULT_NUM_RESULTS
|
data/lib/t/printable.rb
CHANGED
@@ -16,7 +16,7 @@ module T
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def build_long_user(user)
|
19
|
-
[user.id, ls_formatted_time(user), ls_formatted_time(user.status), user.statuses_count, user.favorites_count, user.listed_count, user.friends_count, user.followers_count, "@#{user.screen_name}", user.name, user.verified? ? 'Yes' : 'No', user.protected? ? 'Yes' : 'No', user.description.gsub(/\n+/, ' '), user.status ? decode_full_text(user.status, options['decode_uris']).gsub(/\n+/, ' ') : nil, user.location, user.website.to_s]
|
19
|
+
[user.id, ls_formatted_time(user), ls_formatted_time(user.status), user.statuses_count, user.favorites_count, user.listed_count, user.friends_count, user.followers_count, "@#{user.screen_name}", user.name, user.verified? ? 'Yes' : 'No', user.protected? ? 'Yes' : 'No', user.description.gsub(/\n+/, ' '), user.status? ? decode_full_text(user.status, options['decode_uris']).gsub(/\n+/, ' ') : nil, user.location, user.website.to_s]
|
20
20
|
end
|
21
21
|
|
22
22
|
def csv_formatted_time(object, key = :created_at)
|
@@ -49,7 +49,7 @@ module T
|
|
49
49
|
|
50
50
|
def print_csv_user(user)
|
51
51
|
require 'csv'
|
52
|
-
say [user.id, csv_formatted_time(user), csv_formatted_time(user.status), user.statuses_count, user.favorites_count, user.listed_count, user.friends_count, user.followers_count, user.screen_name, user.name, user.verified?, user.protected?, user.description, user.status ? user.status.full_text : nil, user.location, user.website].to_csv
|
52
|
+
say [user.id, csv_formatted_time(user), csv_formatted_time(user.status), user.statuses_count, user.favorites_count, user.listed_count, user.friends_count, user.followers_count, user.screen_name, user.name, user.verified?, user.protected?, user.description, user.status? ? user.status.full_text : nil, user.location, user.website].to_csv
|
53
53
|
end
|
54
54
|
|
55
55
|
def print_lists(lists)
|
@@ -73,10 +73,10 @@ module T
|
|
73
73
|
print_csv_list(list)
|
74
74
|
end
|
75
75
|
elsif options['long']
|
76
|
-
array = lists.
|
76
|
+
array = lists.collect do |list|
|
77
77
|
build_long_list(list)
|
78
78
|
end
|
79
|
-
format = options['format'] || LIST_HEADINGS.size.times.
|
79
|
+
format = options['format'] || LIST_HEADINGS.size.times.collect { '%s' }
|
80
80
|
print_table_with_headings(array, LIST_HEADINGS, format)
|
81
81
|
else
|
82
82
|
print_attribute(lists, :full_name)
|
@@ -85,7 +85,7 @@ module T
|
|
85
85
|
|
86
86
|
def print_attribute(array, attribute)
|
87
87
|
if STDOUT.tty?
|
88
|
-
print_in_columns(array.
|
88
|
+
print_in_columns(array.collect(&attribute.to_sym))
|
89
89
|
else
|
90
90
|
array.each do |element|
|
91
91
|
say element.send(attribute.to_sym)
|
@@ -98,8 +98,8 @@ module T
|
|
98
98
|
if STDOUT.tty?
|
99
99
|
array.unshift(headings)
|
100
100
|
require 't/core_ext/kernel'
|
101
|
-
array.
|
102
|
-
row.each_with_index.
|
101
|
+
array.collect! do |row|
|
102
|
+
row.each_with_index.collect do |element, index|
|
103
103
|
Kernel.send(element.class.name.to_sym, format[index] % element)
|
104
104
|
end
|
105
105
|
end
|
@@ -130,10 +130,10 @@ module T
|
|
130
130
|
print_csv_tweet(tweet)
|
131
131
|
end
|
132
132
|
elsif options['long']
|
133
|
-
array = tweets.
|
133
|
+
array = tweets.collect do |tweet|
|
134
134
|
build_long_tweet(tweet)
|
135
135
|
end
|
136
|
-
format = options['format'] || TWEET_HEADINGS.size.times.
|
136
|
+
format = options['format'] || TWEET_HEADINGS.size.times.collect { '%s' }
|
137
137
|
print_table_with_headings(array, TWEET_HEADINGS, format)
|
138
138
|
else
|
139
139
|
tweets.each do |tweet|
|
@@ -169,10 +169,10 @@ module T
|
|
169
169
|
print_csv_user(user)
|
170
170
|
end
|
171
171
|
elsif options['long']
|
172
|
-
array = users.
|
172
|
+
array = users.collect do |user|
|
173
173
|
build_long_user(user)
|
174
174
|
end
|
175
|
-
format = options['format'] || USER_HEADINGS.size.times.
|
175
|
+
format = options['format'] || USER_HEADINGS.size.times.collect { '%s' }
|
176
176
|
print_table_with_headings(array, USER_HEADINGS, format)
|
177
177
|
else
|
178
178
|
print_attribute(users, :screen_name)
|
data/lib/t/rcfile.rb
CHANGED
@@ -20,7 +20,7 @@ module T
|
|
20
20
|
if possibilities.size == 1
|
21
21
|
possibilities.first
|
22
22
|
else
|
23
|
-
fail
|
23
|
+
fail(ArgumentError.new("Username #{username} is #{possibilities.size < 1 ? 'not found.' : 'ambiguous, matching ' + possibilities.join(', ')}"))
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
data/lib/t/requestable.rb
CHANGED
data/lib/t/search.rb
CHANGED
@@ -25,10 +25,11 @@ module T
|
|
25
25
|
end
|
26
26
|
|
27
27
|
desc 'all QUERY', "Returns the #{DEFAULT_NUM_RESULTS} most recent Tweets that match the specified query."
|
28
|
-
method_option 'csv', :aliases => '-c', :type => :boolean, :
|
29
|
-
method_option 'decode_uris', :aliases => '-d', :type => :boolean, :
|
30
|
-
method_option 'long', :aliases => '-l', :type => :boolean, :
|
28
|
+
method_option 'csv', :aliases => '-c', :type => :boolean, :desc => 'Output in CSV format.'
|
29
|
+
method_option 'decode_uris', :aliases => '-d', :type => :boolean, :desc => 'Decodes t.co URLs into their original form.'
|
30
|
+
method_option 'long', :aliases => '-l', :type => :boolean, :desc => 'Output in long format.'
|
31
31
|
method_option 'number', :aliases => '-n', :type => :numeric, :default => DEFAULT_NUM_RESULTS
|
32
|
+
method_option 'relative_dates', :aliases => '-a', :type => :boolean, :desc => 'Show relative dates.'
|
32
33
|
def all(query)
|
33
34
|
count = options['number'] || DEFAULT_NUM_RESULTS
|
34
35
|
opts = {:count => MAX_SEARCH_RESULTS}
|
@@ -42,10 +43,10 @@ module T
|
|
42
43
|
say [tweet.id, csv_formatted_time(tweet), tweet.user.screen_name, decode_full_text(tweet, options['decode_uris'])].to_csv
|
43
44
|
end
|
44
45
|
elsif options['long']
|
45
|
-
array = tweets.
|
46
|
+
array = tweets.collect do |tweet|
|
46
47
|
[tweet.id, ls_formatted_time(tweet), "@#{tweet.user.screen_name}", decode_full_text(tweet, options['decode_uris']).gsub(/\n+/, ' ')]
|
47
48
|
end
|
48
|
-
format = options['format'] || TWEET_HEADINGS.size.times.
|
49
|
+
format = options['format'] || TWEET_HEADINGS.size.times.collect { '%s' }
|
49
50
|
print_table_with_headings(array, TWEET_HEADINGS, format)
|
50
51
|
else
|
51
52
|
say unless tweets.empty?
|
@@ -56,10 +57,11 @@ module T
|
|
56
57
|
end
|
57
58
|
|
58
59
|
desc 'favorites [USER] QUERY', "Returns Tweets you've favorited that match the specified query."
|
59
|
-
method_option 'csv', :aliases => '-c', :type => :boolean, :
|
60
|
-
method_option 'decode_uris', :aliases => '-d', :type => :boolean, :
|
61
|
-
method_option 'id', :aliases => '-i', :type => :boolean, :
|
62
|
-
method_option 'long', :aliases => '-l', :type => :boolean, :
|
60
|
+
method_option 'csv', :aliases => '-c', :type => :boolean, :desc => 'Output in CSV format.'
|
61
|
+
method_option 'decode_uris', :aliases => '-d', :type => :boolean, :desc => 'Decodes t.co URLs into their original form.'
|
62
|
+
method_option 'id', :aliases => '-i', :type => :boolean, :desc => 'Specify user via ID instead of screen name.'
|
63
|
+
method_option 'long', :aliases => '-l', :type => :boolean, :desc => 'Output in long format.'
|
64
|
+
method_option 'relative_dates', :aliases => '-a', :type => :boolean, :desc => 'Show relative dates.'
|
63
65
|
def favorites(*args)
|
64
66
|
query = args.pop
|
65
67
|
user = args.pop
|
@@ -86,10 +88,11 @@ module T
|
|
86
88
|
map %w[faves] => :favorites
|
87
89
|
|
88
90
|
desc 'list [USER/]LIST QUERY', 'Returns Tweets on a list that match the specified query.'
|
89
|
-
method_option 'csv', :aliases => '-c', :type => :boolean, :
|
90
|
-
method_option 'decode_uris', :aliases => '-d', :type => :boolean, :
|
91
|
-
method_option 'id', :aliases => '-i', :type => :boolean, :
|
92
|
-
method_option 'long', :aliases => '-l', :type => :boolean, :
|
91
|
+
method_option 'csv', :aliases => '-c', :type => :boolean, :desc => 'Output in CSV format.'
|
92
|
+
method_option 'decode_uris', :aliases => '-d', :type => :boolean, :desc => 'Decodes t.co URLs into their original form.'
|
93
|
+
method_option 'id', :aliases => '-i', :type => :boolean, :desc => 'Specify user via ID instead of screen name.'
|
94
|
+
method_option 'long', :aliases => '-l', :type => :boolean, :desc => 'Output in long format.'
|
95
|
+
method_option 'relative_dates', :aliases => '-a', :type => :boolean, :desc => 'Show relative dates.'
|
93
96
|
def list(list, query)
|
94
97
|
owner, list = extract_owner(list, options)
|
95
98
|
opts = {:count => MAX_NUM_RESULTS}
|
@@ -105,9 +108,10 @@ module T
|
|
105
108
|
end
|
106
109
|
|
107
110
|
desc 'mentions QUERY', 'Returns Tweets mentioning you that match the specified query.'
|
108
|
-
method_option 'csv', :aliases => '-c', :type => :boolean, :
|
109
|
-
method_option 'decode_uris', :aliases => '-d', :type => :boolean, :
|
110
|
-
method_option 'long', :aliases => '-l', :type => :boolean, :
|
111
|
+
method_option 'csv', :aliases => '-c', :type => :boolean, :desc => 'Output in CSV format.'
|
112
|
+
method_option 'decode_uris', :aliases => '-d', :type => :boolean, :desc => 'Decodes t.co URLs into their original form.'
|
113
|
+
method_option 'long', :aliases => '-l', :type => :boolean, :desc => 'Output in long format.'
|
114
|
+
method_option 'relative_dates', :aliases => '-a', :type => :boolean, :desc => 'Show relative dates.'
|
111
115
|
def mentions(query)
|
112
116
|
opts = {:count => MAX_NUM_RESULTS}
|
113
117
|
opts[:include_entities] = !!options['decode_uris']
|
@@ -123,10 +127,11 @@ module T
|
|
123
127
|
map %w[replies] => :mentions
|
124
128
|
|
125
129
|
desc 'retweets [USER] QUERY', "Returns Tweets you've retweeted that match the specified query."
|
126
|
-
method_option 'csv', :aliases => '-c', :type => :boolean, :
|
127
|
-
method_option 'decode_uris', :aliases => '-d', :type => :boolean, :
|
128
|
-
method_option 'id', :aliases => '-i', :type => :boolean, :
|
129
|
-
method_option 'long', :aliases => '-l', :type => :boolean, :
|
130
|
+
method_option 'csv', :aliases => '-c', :type => :boolean, :desc => 'Output in CSV format.'
|
131
|
+
method_option 'decode_uris', :aliases => '-d', :type => :boolean, :desc => 'Decodes t.co URLs into their original form.'
|
132
|
+
method_option 'id', :aliases => '-i', :type => :boolean, :desc => 'Specify user via ID instead of screen name.'
|
133
|
+
method_option 'long', :aliases => '-l', :type => :boolean, :desc => 'Output in long format.'
|
134
|
+
method_option 'relative_dates', :aliases => '-a', :type => :boolean, :desc => 'Show relative dates.'
|
130
135
|
def retweets(*args)
|
131
136
|
query = args.pop
|
132
137
|
user = args.pop
|
@@ -153,12 +158,13 @@ module T
|
|
153
158
|
map %w[rts] => :retweets
|
154
159
|
|
155
160
|
desc 'timeline [USER] QUERY', 'Returns Tweets in your timeline that match the specified query.'
|
156
|
-
method_option 'csv', :aliases => '-c', :type => :boolean, :
|
157
|
-
method_option 'decode_uris', :aliases => '-d', :type => :boolean, :
|
161
|
+
method_option 'csv', :aliases => '-c', :type => :boolean, :desc => 'Output in CSV format.'
|
162
|
+
method_option 'decode_uris', :aliases => '-d', :type => :boolean, :desc => 'Decodes t.co URLs into their original form.'
|
158
163
|
method_option 'exclude', :aliases => '-e', :type => :string, :enum => %w[replies retweets], :desc => 'Exclude certain types of Tweets from the results.', :banner => 'TYPE'
|
159
|
-
method_option 'id', :aliases => '-i', :type => :boolean, :
|
160
|
-
method_option 'long', :aliases => '-l', :type => :boolean, :
|
164
|
+
method_option 'id', :aliases => '-i', :type => :boolean, :desc => 'Specify user via ID instead of screen name.'
|
165
|
+
method_option 'long', :aliases => '-l', :type => :boolean, :desc => 'Output in long format.'
|
161
166
|
method_option 'max_id', :aliases => '-m', :type => :numeric, :desc => 'Returns only the results with an ID less than the specified ID.'
|
167
|
+
method_option 'relative_dates', :aliases => '-a', :type => :boolean, :desc => 'Show relative dates.'
|
162
168
|
method_option 'since_id', :aliases => '-s', :type => :numeric, :desc => 'Returns only the results with an ID greater than the specified ID.'
|
163
169
|
def timeline(*args)
|
164
170
|
query = args.pop
|
@@ -190,11 +196,12 @@ module T
|
|
190
196
|
map %w[tl] => :timeline
|
191
197
|
|
192
198
|
desc 'users QUERY', 'Returns users that match the specified query.'
|
193
|
-
method_option 'csv', :aliases => '-c', :type => :boolean, :
|
194
|
-
method_option 'long', :aliases => '-l', :type => :boolean, :
|
195
|
-
method_option '
|
199
|
+
method_option 'csv', :aliases => '-c', :type => :boolean, :desc => 'Output in CSV format.'
|
200
|
+
method_option 'long', :aliases => '-l', :type => :boolean, :desc => 'Output in long format.'
|
201
|
+
method_option 'relative_dates', :aliases => '-a', :type => :boolean, :desc => 'Show relative dates.'
|
202
|
+
method_option 'reverse', :aliases => '-r', :type => :boolean, :desc => 'Reverse the order of the sort.'
|
196
203
|
method_option 'sort', :aliases => '-s', :type => :string, :enum => %w[favorites followers friends listed screen_name since tweets tweeted], :default => 'screen_name', :desc => 'Specify the order of the results.', :banner => 'ORDER'
|
197
|
-
method_option 'unsorted', :aliases => '-u', :type => :boolean, :
|
204
|
+
method_option 'unsorted', :aliases => '-u', :type => :boolean, :desc => 'Output is not sorted.'
|
198
205
|
def users(query)
|
199
206
|
users = collect_with_page do |page|
|
200
207
|
client.user_search(query, :page => page)
|
data/lib/t/set.rb
CHANGED
@@ -49,7 +49,7 @@ module T
|
|
49
49
|
end
|
50
50
|
|
51
51
|
desc 'profile_background_image FILE', 'Sets the background image on your Twitter profile.'
|
52
|
-
method_option 'tile', :aliases => '-t', :type => :boolean, :
|
52
|
+
method_option 'tile', :aliases => '-t', :type => :boolean, :desc => 'Whether or not to tile the background image.'
|
53
53
|
def profile_background_image(file)
|
54
54
|
client.update_profile_background_image(File.new(File.expand_path(file)), :tile => options['tile'], :skip_status => true)
|
55
55
|
say "@#{@rcfile.active_profile[0]}'s background image has been updated."
|
data/lib/t/stream.rb
CHANGED
@@ -22,15 +22,15 @@ module T
|
|
22
22
|
end
|
23
23
|
|
24
24
|
desc 'all', 'Stream a random sample of all Tweets (Control-C to stop)'
|
25
|
-
method_option 'csv', :aliases => '-c', :type => :boolean, :
|
26
|
-
method_option 'long', :aliases => '-l', :type => :boolean, :
|
25
|
+
method_option 'csv', :aliases => '-c', :type => :boolean, :desc => 'Output in CSV format.'
|
26
|
+
method_option 'long', :aliases => '-l', :type => :boolean, :desc => 'Output in long format.'
|
27
27
|
def all
|
28
28
|
client.before_request do
|
29
29
|
if options['csv']
|
30
30
|
require 'csv'
|
31
31
|
say TWEET_HEADINGS.to_csv
|
32
32
|
elsif options['long'] && STDOUT.tty?
|
33
|
-
headings = TWEET_HEADINGS.size.times.
|
33
|
+
headings = TWEET_HEADINGS.size.times.collect do |index|
|
34
34
|
TWEET_HEADINGS_FORMATTING[index] % TWEET_HEADINGS[index]
|
35
35
|
end
|
36
36
|
print_table([headings])
|
@@ -41,7 +41,7 @@ module T
|
|
41
41
|
if options['csv']
|
42
42
|
print_csv_tweet(tweet)
|
43
43
|
elsif options['long']
|
44
|
-
array = build_long_tweet(tweet).each_with_index.
|
44
|
+
array = build_long_tweet(tweet).each_with_index.collect do |element, index|
|
45
45
|
TWEET_HEADINGS_FORMATTING[index] % element
|
46
46
|
end
|
47
47
|
print_table([array], :truncate => STDOUT.tty?)
|
@@ -60,8 +60,8 @@ module T
|
|
60
60
|
end
|
61
61
|
|
62
62
|
desc 'search KEYWORD [KEYWORD...]', 'Stream Tweets that contain specified keywords, joined with logical ORs (Control-C to stop)'
|
63
|
-
method_option 'csv', :aliases => '-c', :type => :boolean, :
|
64
|
-
method_option 'long', :aliases => '-l', :type => :boolean, :
|
63
|
+
method_option 'csv', :aliases => '-c', :type => :boolean, :desc => 'Output in CSV format.'
|
64
|
+
method_option 'long', :aliases => '-l', :type => :boolean, :desc => 'Output in long format.'
|
65
65
|
def search(keyword, *keywords)
|
66
66
|
keywords.unshift(keyword)
|
67
67
|
require 't/search'
|
@@ -77,7 +77,7 @@ module T
|
|
77
77
|
if options['csv']
|
78
78
|
print_csv_tweet(tweet)
|
79
79
|
elsif options['long']
|
80
|
-
array = build_long_tweet(tweet).each_with_index.
|
80
|
+
array = build_long_tweet(tweet).each_with_index.collect do |element, index|
|
81
81
|
TWEET_HEADINGS_FORMATTING[index] % element
|
82
82
|
end
|
83
83
|
print_table([array], :truncate => STDOUT.tty?)
|
@@ -88,8 +88,8 @@ module T
|
|
88
88
|
end
|
89
89
|
|
90
90
|
desc 'timeline', 'Stream your timeline (Control-C to stop)'
|
91
|
-
method_option 'csv', :aliases => '-c', :type => :boolean, :
|
92
|
-
method_option 'long', :aliases => '-l', :type => :boolean, :
|
91
|
+
method_option 'csv', :aliases => '-c', :type => :boolean, :desc => 'Output in CSV format.'
|
92
|
+
method_option 'long', :aliases => '-l', :type => :boolean, :desc => 'Output in long format.'
|
93
93
|
def timeline
|
94
94
|
require 't/cli'
|
95
95
|
client.before_request do
|
@@ -104,7 +104,7 @@ module T
|
|
104
104
|
if options['csv']
|
105
105
|
print_csv_tweet(tweet)
|
106
106
|
elsif options['long']
|
107
|
-
array = build_long_tweet(tweet).each_with_index.
|
107
|
+
array = build_long_tweet(tweet).each_with_index.collect do |element, index|
|
108
108
|
TWEET_HEADINGS_FORMATTING[index] % element
|
109
109
|
end
|
110
110
|
print_table([array], :truncate => STDOUT.tty?)
|
@@ -115,17 +115,17 @@ module T
|
|
115
115
|
end
|
116
116
|
|
117
117
|
desc 'users USER_ID [USER_ID...]', 'Stream Tweets either from or in reply to specified users (Control-C to stop)'
|
118
|
-
method_option 'csv', :aliases => '-c', :type => :boolean, :
|
119
|
-
method_option 'long', :aliases => '-l', :type => :boolean, :
|
118
|
+
method_option 'csv', :aliases => '-c', :type => :boolean, :desc => 'Output in CSV format.'
|
119
|
+
method_option 'long', :aliases => '-l', :type => :boolean, :desc => 'Output in long format.'
|
120
120
|
def users(user_id, *user_ids)
|
121
121
|
user_ids.unshift(user_id)
|
122
|
-
user_ids.
|
122
|
+
user_ids.collect!(&:to_i)
|
123
123
|
client.before_request do
|
124
124
|
if options['csv']
|
125
125
|
require 'csv'
|
126
126
|
say TWEET_HEADINGS.to_csv
|
127
127
|
elsif options['long'] && STDOUT.tty?
|
128
|
-
headings = TWEET_HEADINGS.size.times.
|
128
|
+
headings = TWEET_HEADINGS.size.times.collect do |index|
|
129
129
|
TWEET_HEADINGS_FORMATTING[index] % TWEET_HEADINGS[index]
|
130
130
|
end
|
131
131
|
print_table([headings])
|
@@ -136,7 +136,7 @@ module T
|
|
136
136
|
if options['csv']
|
137
137
|
print_csv_tweet(tweet)
|
138
138
|
elsif options['long']
|
139
|
-
array = build_long_tweet(tweet).each_with_index.
|
139
|
+
array = build_long_tweet(tweet).each_with_index.collect do |element, index|
|
140
140
|
TWEET_HEADINGS_FORMATTING[index] % element
|
141
141
|
end
|
142
142
|
print_table([array], :truncate => STDOUT.tty?)
|