Skip to content

Commit

Permalink
Validate parameters in config file
Browse files Browse the repository at this point in the history
* Ensure verbose is either true or false
* Ensure integer parameters are valid integers
  • Loading branch information
perldork committed May 14, 2015
1 parent 562a858 commit 1fc9159
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/sidekiq/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,19 @@ def validate!
logger.info @parser
die(1)
end

errors = []
[:concurrency, :index, :timeout].each do |arg|
if options.has_key? arg
Integer(options[arg]) rescue errors.push("#{arg.to_s} must be an integer")
end
end
if options.has_key? :verbose
val = options[:verbose]
errors.push("verbose must be true or false") unless val == true || val == false
end
raise("Invalid configuration found: " + errors.join(", ")) unless errors.empty?

end

def parse_options(argv)
Expand Down

0 comments on commit 1fc9159

Please sign in to comment.