#!/usr/bin/env ruby require "rubygems" require "optparse" require "readline" require "highline" # for testing inside gem dir $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') require "room" def usage puts "usage: room" puts " room for [room name]" exit end def find_room name files = [] files << "#{name}.rb" files << File.join(File.dirname(__FILE__), "..", "rooms", "#{name}.rb") files.find { |f| File.readable? f } end opts = OptionParser.new opts.on("-h", "--help") { usage } opts.parse! ARGV if ARGV.length > 0 if ARGV[0] == "for" && !ARGV[1].nil? @filename = find_room ARGV[1] unless @filename puts "room \"#{ARGV[1]}\" not found" exit 1 end else usage end else @filename = find_room "beginners" end reload! @filename 3.times { Printer.puts } Room.do "look" loop do line = if $secretive $secretive = false HighLine.new.ask("> ") { |q| q.echo = false } else Readline.readline("> ", true) end break unless line Room.do line.chomp end Printer.puts "\nThe world is your cantaloupe."