diff --git a/bin/dhallish b/bin/dhallish index 79b947eac1f7fd9d086d2ad223d35e11f3a785a5..67c8fc4013fe0b44aaaa07bb0e92ac2ca00ad026 100755 --- a/bin/dhallish +++ b/bin/dhallish @@ -12,6 +12,7 @@ pretty_json = false show_type = false read_from_file = nil measure_time = false +basedir = Dir.pwd ARGV.each { |arg| case arg @@ -24,6 +25,7 @@ ARGV.each { |arg| else if File.file?(arg) read_from_file = arg + basedir = File.dirname arg else STDERR.puts "usage: dhallish [--type | --pretty] [file.dhall]" exit! 1 @@ -42,7 +44,7 @@ end time3 = Time.now begin - res, type = Dhallish::evaluate(input) + res, type = Dhallish::evaluate(input, nil, nil, basedir) rescue DhallError => err STDERR.puts err exit! 1 diff --git a/lib/dhallish.rb b/lib/dhallish.rb index f1f3464fca4879765b58420133dfe03b2d85572b..98759bfddab02f451a66c1699edbb59d26ce21ba 100644 --- a/lib/dhallish.rb +++ b/lib/dhallish.rb @@ -25,8 +25,8 @@ module Dhallish end module_function :empty_context - def evaluate(dhallcode, ctx=nil, expected_type=nil) - if ctx.nil?; ctx = empty_context() end + def evaluate(dhallcode, ctx=nil, expected_type=nil, basedir=Dir.pwd) + if ctx.nil?; ctx = empty_context(basedir) end rawast = @@parser.parse dhallcode if rawast.nil?