Class: Cli

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

Constant Summary collapse

COLORS =
{ :green => 32, :red => 31 }

Instance Method Summary collapse

Instance Method Details

#executeObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/cli.rb', line 4

def execute
  validate!
  if ARGV[0] == '--help' || ARGV[0] == '-h'
    print_instructions 
    exit 0
  end
  MalcolmX::find(ARGV) do |response|
    response.each do |x|
      text = "#{x[:domain]} => #{x[:available] ? "available" : "unavailable"}"
      color = x[:available] ? :green : :red
      puts colorize(text, color)
    end
  end
end