Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added #d command line functionality. Also, d now takes stdin for mess…

…age.
  • Loading branch information...
commit 25ddfe33a10a252ff7d9ba74d4d16e3e25719661 1 parent ad2da16
@jnunemaker jnunemaker authored
Showing with 23 additions and 7 deletions.
  1. +6 −1 bin/twitter
  2. +17 −6 lib/twitter/cli.rb
View
7 bin/twitter
@@ -1,10 +1,15 @@
#!/usr/bin/env ruby
-# if we have stdin, let's prepend it to the message
+# if we have stdin, let's prepend it to the message for post
if ARGV[0] && ARGV[0] == 'post' && !STDIN.tty?
ARGV[1] = "#{STDIN.read}#{ARGV[1]}"
end
+# if we have stdin, let's prepend it to the message for d
+if ARGV[0] && ARGV[0] == 'd' && !STDIN.tty?
+ ARGV[2] = "#{STDIN.read}#{ARGV[2]}"
+end
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
require 'twitter'
require 'twitter/cli'
View
23 lib/twitter/cli.rb
@@ -138,12 +138,7 @@ def run
mode 'post' do
def run
do_work do
- post = if ARGV.size > 1
- ARGV.join " "
- else
- ARGV.shift
- end
-
+ post = ARGV.size > 1 ? ARGV.join(" ") : ARGV.shift
say "Sending twitter update"
finished, status = false, nil
progress_thread = Thread.new { until finished; print "."; $stdout.flush; sleep 0.5; end; }
@@ -187,4 +182,20 @@ def run
end
end
end
+
+ mode 'd' do
+ argument('username') {
+ required
+ description 'username or id of twitterrer to direct message'
+ }
+
+ def run
+ do_work do
+ username = params['username'].value
+ post = ARGV.size > 1 ? ARGV.join(" ") : ARGV.shift
+ base.d(username, post)
+ say "Direct message sent to #{username}"
+ end
+ end
+ end
}
Please sign in to comment.
Something went wrong with that request. Please try again.