3
0
Fork 0

.parse takes options (Hash(String,String))

master
Philippe PITTOLI 2019-08-02 17:59:33 +02:00
parent dc53be3544
commit 97b04c2595
2 changed files with 11 additions and 2 deletions

View File

@ -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

View File

@ -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