1
2
3
4
5
6
7
8
9
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
#! /usr/bin/env ruby
# frozen_string_literal: true
# rubocop:disable Style/Documentation
require 'optparse'
require 'colonial_twilight'
class OptParser
class Options
attr_accessor :debug_bot, :clearscreen, :verbose
def initialize
@debug_bot = false
@verbose = false
@gui = false
@clearscreen = false
end
def define_options(parser)
parser.banner = 'Usage: ColonialTwilight.rb [options]'
parser.separator ''
parser.separator 'Specific options:'
add_debug_bot(parser)
add_verbose(parser)
add_gui(parser)
add_clearscreen(parser)
parser.separator ''
parser.separator 'Common options:'
parser.on_tail('-h', '--help', 'Show this message') do
puts parser
exit
end
parser.on_tail('--version', 'Show version') do
puts ColonialTwilight::VERSION
exit
end
end
def add_debug_bot(parser)
parser.on('-d', '--debug_bot', 'Run with FLN bot debug messages') do |v|
@debug_bot = v
end
end
def add_verbose(parser)
parser.on('-v', '--verbose', 'Run more verbose ui') do |_v|
@verbose = true
end
end
def add_gui(parser)
parser.on('-g', '--gui', 'Run in gui mode') do
@gui = true
puts 'gui is not implemented yet ...'
exit
end
end
def add_clearscreen(parser)
parser.on('-c', '--clearscreen', 'Clear screen before each player turn') do |_v|
@clearscreen = true
end
end
end
def parse(args)
@options = Options.new
@parser = OptionParser.new do |parser|
@options.define_options(parser)
parser.parse!(args)
end
@options
end
attr_reader :parser, :options
end
parser = OptParser.new
options = parser.parse(ARGV)
require 'colonial_twilight/cli'
game = ColonialTwilight::Cli.new options
game.start
|