Class: Wordle::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/wordle/options.rb

Instance Method Summary collapse

Instance Method Details

#readObject



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
# File 'lib/wordle/options.rb', line 5

def read
  options = {}

  parser = OptionParser.new do |opts|
    opts.banner = "Usage: wordle [options]"

    opts.on("-iIDENTIFIER", "--identifier=IDENTIFIER", "Pass word identifer to target a specific word that someone else has played. Identifier gets printed at the end of the game to share with a friend.") do |i|
      options[:identifier] = i
    end

    opts.on("-d", "--difficult", "Hard mode. Any revealed hints must be used in subsequent guesses.") do |d|
      options[:difficult] = d
    end

    opts.on("-c", "--contrast", "High contrast mode. Matched letters will be orange. Included letters will be blue.") do |c|
      options[:contrast] = c
    end
  end

  begin
    parser.parse!
  rescue OptionParser::InvalidOption
    puts "Option not recognized"
  end

  options
end