<commit_before>require 'thor'

module SunnyDay
  class CLI < Thor
    class_option :lat, :type => :numeric
    class_option :long, :type => :numeric
    class_option :id, :type => :numeric

    desc 'weather <city>', 'Retrieves current weather for a specific city. You can provide a city name (standard), latitude and longitude or a city id.'
    def weather(city = nil)
      return unless validate(city)
      client.weather(options)
    end

    desc 'forecast <city>', 'Retrieves current forecast for a specific city. You can provide a city name (standard), latitude and longitude or a city id.'
    def forecast(city = nil)
      return unless validate(city)
      client.forecast(options)
    end

    desc 'd_forecast <days> <city>', 'Retrieves daily forecast for a specific city. You can provide a city name (standard), latitude and longitude or a city id.'

    def d_forecast(days, city = nil)
      return unless validate(city)
      options[:cnt] = days
      client.forecast(options)
    end

    option :limit, :type => :numeric
    desc 'find  <city> --limit', 'Searching for city. You can provide a city name (standard) or latitude and longitude.'
    def find(city = nil)
      return unless validate(city)
      options[:cnt] = options[:limit]
      options.delete(:limit) if options.has_key?(:limit)
      client.find(options)
    end

    private

    def validate(city)
      valid = !city.nil? || (!options[:lat].nil? && !options[:long].nil?) || !options[:id].nil?
      puts 'Sorry, your input doesn\’t appear to be valid.' unless valid
      options[:d] = city unless city.nil?
      valid
    end

    def client(config = {})
      SunnyDay.client(config)
    end
  end
end<commit_msg>Paying with options<commit_after>require 'thor'

module SunnyDay
  class CLI < Thor
    class_option :lat, :type => :numeric
    class_option :long, :type => :numeric
    class_option :id, :type => :numeric

    desc 'weather <city>', 'Retrieves current weather for a specific city. You can provide a city name (standard), latitude and longitude or a city id.'
    def weather(city = nil)
      return unless validate(city)
      client.weather(options)
    end

    desc 'forecast <city>', 'Retrieves current forecast for a specific city. You can provide a city name (standard), latitude and longitude or a city id.'
    def forecast(city = nil)
      return unless validate(city)
      client.forecast(w_options)
    end

    desc 'd_forecast <days> <city>', 'Retrieves daily forecast for a specific city. You can provide a city name (standard), latitude and longitude or a city id.'

    def d_forecast(days, city = nil)
      return unless validate(city)
      opts = w_options
      opts[:cnt] = days
      client.forecast(opts)
    end

    option :limit, :type => :numeric
    desc 'find  <city> --limit', 'Searching for city. You can provide a city name (standard) or latitude and longitude.'
    def find(city = nil)
      return unless validate(city)
      opts = w_options
      opts[:cnt] = options[:limit]
      opts.delete(:limit) if opts.has_key?(:limit)
      client.find(opts)
    end

    private

    def validate(city)
      valid = !city.nil? || (!options[:lat].nil? && !options[:long].nil?) || !options[:id].nil?
      puts 'Sorry, your input doesn’t appear to be valid. Use "sunnyday help" for available options.' unless valid
      valid
    end

    def w_options
      opts = options.dup
      opts[:d] = city unless city.nil?
      opts
    end

    def client(config = {})
      SunnyDay.client(config)
    end
  end
end
{'fraction_non_alphanumeric': 0.10623946037099494, 'fraction_numerical': 0.0, 'mean_word_length': 2.9720982142857144, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1414529', 'n_tokens_mistral': 1058, 'n_tokens_neox': 1024, 'n_words': 387}