diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2020-08-05 19:14:26 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2020-08-05 19:14:26 +0200 |
commit | 94d2e329a4b9c325b32de5bd641e5e1e99a1c8f4 (patch) | |
tree | 1d9f733e12eb8dc27610da0d52674ae1aec9fefc /bin | |
download | colonial-twilight-94d2e329a4b9c325b32de5bd641e5e1e99a1c8f4.zip colonial-twilight-94d2e329a4b9c325b32de5bd641e5e1e99a1c8f4.tar.gz |
Inital commit
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/ColonialTwilight.rb | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/bin/ColonialTwilight.rb b/bin/ColonialTwilight.rb new file mode 100755 index 0000000..9a376c9 --- /dev/null +++ b/bin/ColonialTwilight.rb @@ -0,0 +1,77 @@ +#! /usr/bin/env ruby +# -*- coding: UTF-8 -*- + +require 'optparse' + +require 'colonial_twilight' + +class OptParser + + class Options + + attr_accessor :verbose, :clearscreen + + def initialize + @verbose = false + @gui = false + @clearscreen = false + end + + def define_options(parser) + parser.banner = "Usage: ColonialTwilight.rb [options]" + parser.separator "" + parser.separator "Specific options:" + + 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_verbose(parser) + parser.on("-v", "--[no-]verbose", "Run verbosely") do |v| + @verbose = v + end + end + def add_gui(parser) + parser.on("-g", "--gui", "Run verbosely") 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 |