# frozen_string_literal: true require_relative "base" module Neetob class CLI module Github class Search < Base attr_accessor :apps, :key_to_search, :search_file_path, :sandbox def initialize(apps, key_to_search, search_file_path, sandbox = false) super() @apps = apps @key_to_search = key_to_search @search_file_path = search_file_path @sandbox = sandbox end def run matching_apps = find_all_matching_apps(apps, :github, sandbox) matching_apps.each do |app| begin ui.info("\n Searching in \"#{app}/#{search_file_path}\" for \"#{key_to_search}\"\n") content = Base64.decode64(client.contents(app, 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