Sha256: cc02bba8f32d2b163482ff922880f552aac995d0559dcbed82518a904a0ed7c0

Contents?: true

Size: 578 Bytes

Versions: 6

Compression:

Stored size: 578 Bytes

Contents

# frozen_string_literal: true

require "json"
require "thor"

module UrlScan
  module Commands
    class Base < Thor
      class_option :API_KEY, type: :string

      no_commands do
        def api
          options.key?("API_KEY") ? API.new(options["API_KEY"]) : API.new
        end

        def with_error_handling
          yield
        rescue ArgumentError => _e
          puts "Warning: please specify your urlscan.io API key via ENV['URLSCAN_API_KEY'] or --API-KEY"
        rescue ResponseError => e
          puts "Warning: #{e}"
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
urlscan-0.8.0 lib/urlscan/commands/base.rb
urlscan-0.7.0 lib/urlscan/commands/base.rb
urlscan-0.6.0 lib/urlscan/commands/base.rb
urlscan-0.5.0 lib/urlscan/commands/base.rb
urlscan-0.4.1 lib/urlscan/commands/base.rb
urlscan-0.4.0 lib/urlscan/commands/base.rb