def run
      options.staged = options.staged.nil? ? true : options.staged

      if options.skip_pre
        puts 'Skipping PreRun Executables'
      else
        run_externals('pre-run-execute')
      end

      if script && !(options.ignore_script || GitHooks.ignore_script)
        command = "#{script} #{Pathname.new($0)} #{Shellwords.join(ARGV)};"
        puts "Kernel#exec(#{command.inspect})" if GitHooks.verbose
        exec(command)
      elsif hook_path
        load_tests && start
      else
        puts %q"I can't figure out what to run! Specify either path or script to give me a hint..."
      end

      if options.skip_post
        puts 'Skipping PostRun Executables'
      else
        run_externals('post-run-execute')
      end
    rescue SystemStackError => e
      puts "#{e.class.name}: #{e.message}\n\t#{e.backtrace.join("\n\t")}"
    rescue GitHooks::Error::NotAGitRepo => e
      puts "Unable to find a valid git repo in #{repository}."
      puts 'Please specify path to repository via --repo <path>' if GitHooks::SCRIPT_NAME == 'githooks'
      raise e
    end
def run
      options.staged = options.staged.nil? ? true : options.staged

      if options.skip_pre
        puts 'Skipping PreRun Executables'
      else
        run_externals('pre-run-execute')
      end

      if script && !(options.ignore_script || GitHooks.ignore_script)
        command = "#{script} #{Pathname.new($0)} #{Shellwords.join(ARGV)};"
        puts "Kernel#exec(#{command.inspect})" if GitHooks.verbose
        exec(command)
      elsif hook_path
        load_tests && start
      else
        puts %q"I can't figure out what to run! Specify either path or script to give me a hint..."
      end

      if options.skip_post
        puts 'Skipping PostRun Executables'
      else
        run_externals('post-run-execute')
      end
    rescue SystemStackError => e
      puts "#{e.class.name}: #{e.message}\n\t#{e.backtrace.join("\n\t")}"
    rescue GitHooks::Error::NotAGitRepo => e
      puts "Unable to find a valid git repo in #{repository}."
      puts 'Please specify path to repository via --repo <path>' if GitHooks::SCRIPT_NAME == 'githooks'
      raise e
    end
rubocop:disable CyclomaticComplexity, MethodLength, AbcSize, PerceivedComplexity