Skip to content

Commit

Permalink
Merge pull request #300 from patmaddox/298-t-reply-opens-text-editor
Browse files Browse the repository at this point in the history
Reply without a status opens a text editor
  • Loading branch information
sferik committed Dec 5, 2015
2 parents bff21e4 + 31574da commit 707cdf3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/t/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -596,11 +596,12 @@ def reach(tweet_id)
say number_with_delimiter(reach.size)
end

desc 'reply TWEET_ID MESSAGE', 'Post your Tweet as a reply directed at another person.'
desc 'reply TWEET_ID [MESSAGE]', 'Post your Tweet as a reply directed at another person.'
method_option 'all', aliases: '-a', type: :boolean, desc: 'Reply to all users mentioned in the Tweet.'
method_option 'location', aliases: '-l', type: :string, default: nil, desc: "Add location information. If the optional 'latitude,longitude' parameter is not supplied, looks up location by IP address."
method_option 'file', aliases: '-f', type: :string, desc: 'The path to an image to attach to your tweet.'
def reply(status_id, message)
def reply(status_id, message = nil)
message = T::Editor.gets if message.to_s.empty?
status = client.status(status_id.to_i, include_my_retweet: false)
users = Array(status.user.screen_name)
if options['all']
Expand Down Expand Up @@ -846,7 +847,7 @@ def unfollow(user, *users)
method_option 'location', aliases: '-l', type: :string, default: nil, desc: "Add location information. If the optional 'latitude,longitude' parameter is not supplied, looks up location by IP address."
method_option 'file', aliases: '-f', type: :string, desc: 'The path to an image to attach to your tweet.'
def update(message = nil)
message = T::Editor.gets if message.nil? || message.empty?
message = T::Editor.gets if message.to_s.empty?
opts = {trim_user: true}
add_location!(options, opts)
status = if options['file']
Expand Down
12 changes: 12 additions & 0 deletions spec/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2597,6 +2597,12 @@
expect($stdout.string.split("\n").first).to eq 'Reply posted by @testcli to @joshfrench.'
end
end
context 'no status provided' do
it 'opens an editor to prompt for the status' do
expect(T::Editor).to receive(:gets).and_return 'Testing'
@cli.reply('263813522369159169')
end
end
end

describe '#report_spam' do
Expand Down Expand Up @@ -3927,6 +3933,12 @@
expect($stdout.string.split("\n").first).to eq 'Tweet posted by @testcli.'
end
end
context 'no status provided' do
it 'opens an editor to prompt for the status' do
expect(T::Editor).to receive(:gets).and_return 'Testing'
@cli.update
end
end
end

describe '#users' do
Expand Down

0 comments on commit 707cdf3

Please sign in to comment.