.parse takes options (Hash(String,String))
parent
dc53be3544
commit
97b04c2595
|
@ -349,7 +349,7 @@ class Specs
|
|||
has_bugs
|
||||
end
|
||||
|
||||
def self.parse(file_name : String) : Specs | Nil
|
||||
def self.parse(file_name : String, options : Hash(String, String) | Nil = nil) : Specs | Nil
|
||||
begin
|
||||
content = File.read(file_name)
|
||||
content = content.rchop
|
||||
|
@ -360,6 +360,12 @@ class Specs
|
|||
end
|
||||
|
||||
specs = Specs.new
|
||||
unless options.nil?
|
||||
options.each do |opt, val|
|
||||
specs.assignments[opt] = StringContainer.new val
|
||||
end
|
||||
end
|
||||
|
||||
tree = Pegasus::Generated.process(content)
|
||||
specs.parse_tree tree
|
||||
|
||||
|
|
|
@ -28,5 +28,8 @@ OptionParser.parse! do |parser|
|
|||
end
|
||||
|
||||
|
||||
specs = Specs.parse recipe_file_name
|
||||
options = Hash(String,String).new
|
||||
options["someoptionexample"] = "option"
|
||||
|
||||
specs = Specs.parse recipe_file_name, options
|
||||
pp! specs
|
||||
|
|
Reference in New Issue