#! /usr/bin/env ruby require_relative '../lib/haxor' require 'optparse' parser = OptionParser.new do |opts| opts.banner = 'Usage: hvm [options] [file.hax.e]' opts.on_tail('-h', '--help', 'Show this message') do puts opts exit end opts.on_tail('-v', '--version', 'Show version') do puts "Haxor, version #{Haxor::Consts::GEM_VERSION}, version id #{Haxor::Consts::VERSION}." exit end end parser.parse! if ARGV[0].nil? puts 'You must specify .hax.e file to be run.' puts parser exit end begin vm = Haxor::Vm::Core.new filename = ARGV[0] # make life easier ;) filename += '.e' if filename.end_with? '.hax' vm.load_program filename vm.execute rescue => e puts "An error occurred: #{e}." exit 1 end