lib/tw/app/main.rb in tw-0.2.6 vs lib/tw/app/main.rb in tw-0.3.0
- old
+ new
@@ -51,10 +51,11 @@
arg 'dm:to', 'create direct message'
arg :search, 'search public timeline', :alias => :s
arg :stream, 'show user stream', :alias => :st
arg :pipe, 'pipe tweet'
arg :format, 'output format', :default => 'text'
+ arg :silent, 'silent mode'
arg :version, 'show version', :alias => :v
arg :help, 'show help', :alias => :h
validate :user, 'invalid user name' do |v|
v =~ /^[a-zA-Z0-9_]+$/
@@ -87,10 +88,12 @@
STDERR.puts " tw --format=json"
STDERR.puts ' tw --format="@#{user} #{text} - http://twitter.com/#{user}/#{id}"'
on_exit
end
+ Render.silent = @parser[:silent]
+
regist_cmds
cmds.each do |name, cmd|
next unless @parser[name]
cmd.call @parser[name], @parser
@@ -116,10 +119,14 @@
else
puts "tweet \"#{message}\"? (#{len} chars)"
puts '[Y/n]'
on_exit if STDIN.gets.strip =~ /^n/i
end
- client.tweet message
+ begin
+ client.tweet message
+ rescue => e
+ STDERR.puts e.message
+ end
end
end
private
def auth