Sha256: 8b4eb932179a58359082cc82905e0243dafffe7756803cf339d45a8e73c471c0
Contents?: true
Size: 1.37 KB
Versions: 7
Compression:
Stored size: 1.37 KB
Contents
#!/usr/bin/env ruby require 'optparse' require_relative '../lib/gemwarrior/misc/version' require_relative '../lib/gemwarrior/game' GAME_NAME = "Gem Warrior" def parse_options options = {:debug_mode => false, :god_mode => false, :beast_mode => false, :use_wordnik => false} optparse = OptionParser.new do |opts| opts.on('-v', '--version', 'Display version number and exit') do puts "#{GAME_NAME} v#{Gemwarrior::VERSION}" exit end opts.on('-d', '--debug', 'Turn debug on') do options[:debug_mode] = true end opts.on('-g', '--god', 'Set godmode to true on load') do options[:god_mode] = true end opts.on('-b', '--beast', 'Set beastmode to true on load') do options[:beast_mode] = true end opts.on('-w', '--wordnik', 'Use Wordnik to generate more diverse, dynamic descriptors of entities') do options[:use_wordnik] = true end end optparse.parse!() return options end def print_error(error) case error when OptionParser::InvalidOption puts "#{$PROGRAM_NAME}: illegal option #{error.args.join(' ')}" else puts "An unexpected error occurred while running #{$PROGRAM_NAME}:" puts " #{error}\n" end end begin options = parse_options Gemwarrior::Game.new(options) rescue => error print_error(error) exit(false) end
Version data entries
7 entries across 7 versions & 1 rubygems