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 = " Display latest twitter search results. Even poll for them for hours of fun.\n \n Usage: \#{File.basename($0)} [options]\n \n Options are:\n BANNER\n opts.separator \"\"\n opts.on(\"-f\", \"Poll for new search results each 15 seconds.\"\n ) { |arg| options[:polling] = true }\n opts.on(\"-h\", \"--help\",\n \"Show this help message.\") { stdout.puts opts; exit }\n opts.parse!(arguments)\n end\n \n unless query = arguments.shift\n stdout.puts parser\n exit\n end\n\n begin\n app = TweetTail::TweetPoller.new(query)\n app.refresh\n stdout.puts app.render_latest_results\n while(options[:polling])\n Kernel::sleep(15)\n app.refresh\n if app.render_latest_results.size > 0\n stdout.puts app.render_latest_results\n end\n end\n rescue Interrupt\n end\nend\n".gsub(/^ /,'')
|