3
0

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

This commit is contained in:
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 has_bugs
end end
def self.parse(file_name : String) : Specs | Nil def self.parse(file_name : String, options : Hash(String, String) | Nil = nil) : Specs | Nil
begin begin
content = File.read(file_name) content = File.read(file_name)
content = content.rchop content = content.rchop
@ -360,6 +360,12 @@ class Specs
end end
specs = Specs.new specs = Specs.new
unless options.nil?
options.each do |opt, val|
specs.assignments[opt] = StringContainer.new val
end
end
tree = Pegasus::Generated.process(content) tree = Pegasus::Generated.process(content)
specs.parse_tree tree specs.parse_tree tree

View File

@ -28,5 +28,8 @@ OptionParser.parse! do |parser|
end end
specs = Specs.parse recipe_file_name options = Hash(String,String).new
options["someoptionexample"] = "option"
specs = Specs.parse recipe_file_name, options
pp! specs pp! specs