Sha256: 16d7af00af8191c06aebe99b9acd3cd3b7e0042ab91410f21848ae06fc996338

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

require 'thor'
require 'kovid'

module Kovid
  class CLI < Thor
    FULL_FLAG = %w[-f --full].freeze

    desc 'define', 'Defines COVID-19'
    def define
      puts Kovid::Nineteen.whatis
    end

    desc 'check COUNTRY', 'Returns reported data on provided country'
    method_option :full, aliases: '-f'
    def check(name)
      if options[:full]
        puts Kovid::Nineteen.country_full(name)
      else
        puts Kovid::Nineteen.country(name)
      end
    end

    desc 'state STATE', 'Return reported data on provided state'
    def state(state)
      puts Kovid::Nineteen.state(state)
    end

    desc 'compare COUNTRY COUNTRY', 'Returns full comparison table for given countries. Accepts multiple countries'
    def compare(*name)
      if FULL_FLAG.include?(name.fetch(-1))
        name = name.reverse.drop(1).reverse
        puts Kovid::Nineteen.country_comparison_full(name)
      else
        puts Kovid::Nineteen.country_comparison(name)
      end
    end

    desc 'cases', 'Returns total number of cases, deaths and recoveries'
    def cases
      puts Kovid::Nineteen.cases
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kovid-0.1.13 lib/kovid/cli.rb