lib/clickatell/utility/options.rb in clickatell-0.7.0 vs lib/clickatell/utility/options.rb in clickatell-0.7.1
- old
+ new
@@ -4,11 +4,11 @@
module Clickatell
module Utility
class Options #:nodoc:
class << self
- def parse(args)
+ def parse(args)
@options = self.default_options
parser = OptionParser.new do |opts|
opts.banner = "Usage: sms [options] recipient(s) message"
opts.separator " Recipients can be a comma-separated list, up to 100 max."
opts.separator ""
@@ -62,21 +62,20 @@
opts.on_tail('-v', '--version') do
puts "Ruby Clickatell SMS Utility #{Clickatell::VERSION}"
exit
end
end
-
+
+ @options.recipient = args[-2].split(',') rescue nil
+ @options.message = args[-1]
+
parser.parse!(args)
- @options.recipient = ARGV[-2]
- @options.message = ARGV[-1]
if (@options.message.nil? || @options.recipient.nil?) && send_message?
puts "You must specify a recipient and message!"
puts parser
exit
end
-
- @options.recipient = @options.recipient.split(",")
return @options
rescue OptionParser::MissingArgument => e
switch_given = e.message.split(':').last.strip