Sha256: c498ce8a3076d3ab9f8a56812b9c768897a721b7556fe10f3e6784e2d098cfa3

Contents?: true

Size: 884 Bytes

Versions: 1

Compression:

Stored size: 884 Bytes

Contents

# frozen_string_literal: true

require "thor"

require "json"

module Tansaku
  class CLI < Thor
    desc "crawl URL", "Crawl a given URL"
    method_option :additional_list, desc: "Path to the file which includes additonal paths to crawl"
    method_option :host, type: :string, desc: "Host header to use"
    method_option :max_concurrent_requests, type: :numeric, desc: "Number of concurrent requests to use"
    method_option :type, desc: "Type of a list to crawl (admin, backup, database, etc, log or all)", default: "all"
    method_option :user_agent, type: :string, desc: "User-Agent header to use"
    def crawl(url)
      params = options.compact.map { |k, v| [k.to_sym, v] }.to_h
      begin
        crawler = Crawler.new(url, **params)
        results = crawler.crawl
        puts results.to_json
      rescue ArgumentError => e
        puts e
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tansaku-1.0.0 lib/tansaku/cli.rb