# frozen_string_literal: true require_relative "base" module Neetob class CLI module Github class Search < Base attr_accessor :repos, :key_to_search, :search_file_path, :sandbox def initialize(repos, key_to_search, search_file_path, sandbox = false) super() @repos = repos @key_to_search = key_to_search @search_file_path = search_file_path @sandbox = sandbox end def run matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox) matching_repos.each do |repo| begin ui.info("\n Searching in \"#{repo}/#{search_file_path}\" for \"#{key_to_search}\"\n") content = Base64.decode64(client.contents(repo, path: search_file_path).content) ui.error("Keyword not found") and next unless content.include? key_to_search content.each_line do |line| ui.success(line) if line.include?(key_to_search) end rescue StandardError => e ExceptionHandler.new(e).process end end end end end end end