Sha256: 734837d28806edd1cbec41bbeb86caef117bd7c60a98921e22f475c4d403552d

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 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.whatis
    end

    desc 'check COUNTRY or check "COUNTRY NAME"', 'Returns reported data on provided country. eg: "kovid check "hong kong".'
    method_option :full, aliases: '-f'
    def check(name)
      if options[:full]
        puts Kovid.country_full(name)
      else
        puts Kovid.country(name)
      end
    end
    desc 'country COUNTRY or country "COUNTRY NAME"', 'Returns reported data on provided country. eg: "kovid country "hong kong".'
    alias country check

    desc 'state STATE', 'Return reported data on provided state.'
    def state(state)
      puts Kovid.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))
        puts Kovid.country_comparison_full(name[0..-2])
      else
        puts Kovid.country_comparison(name)
      end
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kovid-0.2.0 lib/kovid/cli.rb
kovid-0.1.15 lib/kovid/cli.rb