bin/tw in tw-0.0.1 vs bin/tw in tw-0.0.2

- old
+ new

@@ -1,39 +1,8 @@ #!/usr/bin/env ruby -require File.expand_path '../lib/tw', File.dirname(__FILE__) +$:.unshift File.expand_path '../lib', File.dirname(__FILE__) +require 'rubygems' +require 'tw' +require 'tw/app/main' -c = Tw::Client.new - -if ARGV.size < 1 - Tw::Render.display c.mentions -elsif Tw::Opts.all_cmds? ARGV - Tw::Render.display ARGV.map{|arg| - if word = Tw::Opts.search_word?(arg) - res = c.search word - elsif user = Tw::Opts.username?(arg) - res = c.user_timeline user - elsif (user, list = Tw::Opts.listname?(arg)) != false - res = c.list_timeline(user, list) - end - res - } -else - if ARGV.size == 1 and ARGV.first =~ /^-+$/ - ARGF.each do |line| - line.split(/(.{140})/u).select{|m|m.size>0}.each do |message| - c.tweet message - end - sleep 1 - end - else - message = ARGV.join(' ') - if (len = message.split(//u).size) > 140 - puts "tweet too long (#{len} chars)" - exit 1 - else - puts "tweet \"#{message}\"? (#{len} chars)" - puts '[Y/n]' - exit if STDIN.gets.strip =~ /^n/i - end - c.tweet message - end -end +app = Tw::App.new +app.run ARGV