diff --git a/lib/t/cli.rb b/lib/t/cli.rb index d43fdeab..73f09e7b 100644 --- a/lib/t/cli.rb +++ b/lib/t/cli.rb @@ -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'] @@ -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'] diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb index 53797667..b1ae18b4 100644 --- a/spec/cli_spec.rb +++ b/spec/cli_spec.rb @@ -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 @@ -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