Sha256: ba12f7cc168cbf7ebd8a9461d30048b4d55aad208b7248c23539a0310ff1e5c6
Contents?: true
Size: 1.48 KB
Versions: 2
Compression:
Stored size: 1.48 KB
Contents
#!/usr/bin/env ruby require 'optparse' require_relative '../lib/gemwarrior/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, :sound => 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 opts.on('-s', '--sound', 'Turn sound on') do options[:sound] = 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gemwarrior-0.8.6 | bin/gemwarrior |
gemwarrior-0.8.5 | bin/gemwarrior |