Permalink
Browse files

add argument in constructor in order to parse another array than ARGV

  • Loading branch information...
1 parent 864c0fc commit 0f919980af6707c66c67e019567b8508ae8efefe @miaoufkirsh miaoufkirsh committed Apr 15, 2011
Showing with 4 additions and 3 deletions.
  1. +4 −3 lib/micro-optparse/parser.rb
@@ -4,7 +4,8 @@
class Parser
attr_accessor :banner, :version
- def initialize
+ def initialize(argv = ARGV)
+ @argv = argv
@options = []
@used_short = []
yield self
@@ -59,12 +60,12 @@ def process!
end
begin
- optionparser.parse!(ARGV)
+ optionparser.parse!(@argv)
rescue OptionParser::ParseError => e
puts e.message ; exit(1)
end
validate(options) if self.respond_to?("validate")
options
end
-end
+end

0 comments on commit 0f91998

Please sign in to comment.