Class: Minesweeprb::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/minesweeprb/cli.rb

Defined Under Namespace

Classes: Error

Class Method Summary collapse

Class Method Details

.start(argv = ARGV) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/minesweeprb/cli.rb', line 10

def self.start(argv = ARGV)
  options = {}

  parser = OptionParser.new do |opts|
    opts.banner = 'Usage: minesweeprb [options]'

    opts.on('-v', '--version', 'Print version') do
      require_relative 'version'
      puts "v#{Minesweeprb::VERSION}"
      exit
    end

    opts.on('-t', '--theme NAME', 'Theme (classic, modern)') do |name|
      options[:theme] = name
    end

    opts.on('-h', '--help', 'Show this help') do
      puts opts
      exit
    end
  end

  parser.parse!(argv)

  require_relative 'commands/play'
  Commands::Play.new(options).execute
end