4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/tweet-tail/cli.rb', line 4
def self.execute(stdout, arguments=[])
options = { :polling => false }
parser = OptionParser.new do |opts|
opts.banner = <<-BANNER.gsub(/^ /,'')
Display latest twitter search results. Even poll for them for hours of fun.
Usage: #{File.basename($0)} [options]
Options are:
BANNER
opts.separator ""
opts.on("-f", "Poll for new search results each 15 seconds."
) { |arg| options[:polling] = true }
opts.on("-h", "--help",
"Show this help message.") { stdout.puts opts; exit }
opts.parse!(arguments)
end
unless query = arguments.shift
stdout.puts parser
exit
end
begin
app = TweetTail::TweetPoller.new(query)
app.refresh
stdout.puts app.render_latest_results
while(options[:polling])
Kernel::sleep(15)
app.refresh
if app.render_latest_results.size > 0
stdout.puts app.render_latest_results
end
end
rescue Interrupt
end
end
|