Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thor does not like options.delete #332

Merged
merged 1 commit into from
Mar 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions bin/cli/sqs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ def ls(queue_name_prefix = '')
loop do
list_and_print_queues(urls)

break unless options.watch
break unless options[:watch]

sleep options.watch_interval
sleep options[:watch_interval]
puts
end
end
Expand All @@ -123,7 +123,7 @@ def ls(queue_name_prefix = '')
method_option :path, aliases: '-p', type: :string, default: './', desc: 'path to save the dump file'
method_option :delete, aliases: '-d', type: :boolean, default: true, desc: 'delete from the queue'
def dump(queue_name)
path = dump_file(options.path, queue_name)
path = dump_file(options[:path], queue_name)

fail_task "File #{path} already exists" if File.exist?(path)

Expand All @@ -133,15 +133,15 @@ def dump(queue_name)

file = nil

count = find_all(url, options.number) do |m|
count = find_all(url, options[:number]) do |m|
file ||= File.open(path, 'w')

file.puts(JSON.dump(m.to_h))

messages << m if options.delete
messages << m if options[:delete]
end

batch_delete(url, messages) if options.delete
batch_delete(url, messages) if options[:delete]

if count.zero?
say "Queue #{queue_name} is empty", :yellow
Expand Down Expand Up @@ -170,12 +170,12 @@ def mv(queue_name_source, queue_name_target)
url_source = find_queue_url(queue_name_source)
messages = []

count = find_all(url_source, options.number) do |m|
count = find_all(url_source, options[:number]) do |m|
messages << m
end

batch_send(find_queue_url(queue_name_target), messages.map(&:to_h))
batch_delete(url_source, messages) if options.delete
batch_delete(url_source, messages) if options[:delete]

if count.zero?
say "Queue #{queue_name_source} is empty", :yellow
Expand Down
4 changes: 2 additions & 2 deletions bin/shoryuken
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ module Shoryuken
opts = options.to_h.symbolize_keys

# Keep compatibility with old CLI queue format
opts[:queues] = options.queues.map { |q| q.split(',') } if options.queues
opts[:queues] = options[:queues].map { |q| q.split(',') } if options[:queues]

if options.daemon && options.logfile.nil?
if options[:daemon] && options[:logfile].nil?
fail_task "You should set a logfile if you're going to daemonize"
end

Expand Down