#!/usr/bin/env ruby require File.expand_path '../lib/tw', File.dirname(__FILE__) 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