#!/usr/bin/env ruby require File.join(File.dirname(__FILE__), "..", "lib", "maths") # The main script! parser = Maths::Calculator.new puts puts "Welcome to maths (version #{Maths::VERSION})!" puts "Type \"exit\" to quit." puts Readline.completion_proc = Proc.new do |str| # TODO: Get this working end prompt = "maths> " while command = Readline.readline(prompt, true) break if /exit/i =~ command if command == "vars" || command == "variables" puts puts "Defined Variables:" Maths::Brain.read.each do |key, value| puts "#{key}: #{value}" end puts else begin puts "= #{parser.parse(command)}" rescue ParseError puts $! end end end