Sha256: 48b0db90440f540abf75f7acf1669551867ffec2c33b4aa6ef9d366367bb8c7b

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 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}

  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
  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

5 entries across 5 versions & 1 rubygems

Version Path
gemwarrior-0.7.2 bin/gemwarrior
gemwarrior-0.7.1 bin/gemwarrior
gemwarrior-0.7.0 bin/gemwarrior
gemwarrior-0.6.5 bin/gemwarrior
gemwarrior-0.6.4 bin/gemwarrior