Sha256: f95421ae0476b4e18fcd9f4ef05a7d8d76d9ab873c601c95dcc0e74e2cf22f94

Contents?: true

Size: 803 Bytes

Versions: 1

Compression:

Stored size: 803 Bytes

Contents

#!/usr/bin/env ruby

require 'optparse'

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '/../lib'))

require 'pokeedex'

options = { query: ARGV[0] }

OptionParser.new do |opts|
  opts.banner = 'Usage: pokeedex [number|name]'

  opts.on('-h', '--help', 'Prints this help') do
    puts opts
    exit
  end
end.parse!

if ARGV.empty?
  warn 'You need to introduce a number or name of a Pokemon'
  warn "USAGE: #{$PROGRAM_NAME} [number|name]"
  exit 1
end

Pokeedex.init

begin
  pokemons = Pokeedex::Pokemon::Base.search(options[:query])
rescue Pokeedex::Exceptions::ScrapperError => e
  warn e.message
  exit 1
end

if pokemons.empty?
  warn "\nNo information found about the pokemon or criteria"
  exit 1
end

pokemons.each do |pokemon|
  puts Pokeedex::Pokemon::Decorators::Base.new(pokemon)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pokeedex-0.1.5 bin/pokeedex