module KPM::Tasks

def tenant_config

def tenant_config
  logger.info 'Please wait processing the request!!!'
  begin
    if options[:killbill_url] && /https?:\/\/[\S]+/.match(options[:killbill_url]).nil?
      raise Interrupt,'--killbill_url, required format -> http(s)://something'
    end
    if options[:killbill_api_credentials] && options[:killbill_api_credentials].size != 2
      raise Interrupt,'--killbill_api_credentials, required format -> <api_key> <api_secrets>'
    end
    if options[:killbill_credentials] && options[:killbill_credentials].size != 2
      raise Interrupt,'--killbill_credentials, required format -> <user> <password>'
    end
    if options[:key_prefix] === :key_prefix.to_s
      raise Interrupt, "--key_prefix, posible values #{KPM::TenantConfig::KEY_PREFIXES.join(', ')}"
    end
    tenantConfig = KPM::TenantConfig.new(options[:killbill_api_credentials],options[:killbill_credentials],
                               options[:killbill_url], logger)
    tenantConfig.export(options[:key_prefix])
  rescue Exception => e
    logger.error "\e[91;1m#{e.message}\e[0m"
    if not e.is_a?(Interrupt)
      logger.error e.backtrace.join("\n")
    end
  end
end