.parse takes options (Hash(String,String))
This commit is contained in:
parent
dc53be3544
commit
97b04c2595
@ -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
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
Reference in New Issue
Block a user