Sha256: e047391ad97e7fd2c4ce323828ca3ef6d510ef95171b4c335e290db1351e732d

Contents?: true

Size: 1.08 KB

Versions: 7

Compression:

Stored size: 1.08 KB

Contents

require 'commander'

module Elsmore
  class Command
    include Commander::Methods

    attr_accessor :emitter

    def initialize
      self.emitter = Elsmore::Emitter.new
    end

    def run
      program :name, 'elsmore'
      program :version, Elsmore::VERSION
      program :description, 'A convenient scraper for archiving sites'
      program :help, 'Author', 'Cristiano Betta <cristiano@betta.io>'

      command :snap do |c|
        c.syntax = 'spider <url> [options]'
        c.description = 'Spiders a URL within from the given page, sticking within the original domain'
        c.action do |args, options|
          scraper = Elsmore::Scraper.new(args.first)
          scraper.emitter = emitter
          result = scraper.run

          emitter.newline
          emitter.newline
          emitter.say "Processed"
          emitter.pretty result[:processed]
          emitter.newline
          emitter.say "Could not be processed"
          emitter.pretty result[:invalid]
        end
      end
      alias_command :'go fetch', :'snap'
      default_command :snap


      run!
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
elsmore-0.1.7 lib/elsmore/command.rb
elsmore-0.1.6 lib/elsmore/command.rb
elsmore-0.1.5 lib/elsmore/command.rb
elsmore-0.1.4 lib/elsmore/command.rb
elsmore-0.1.3 lib/elsmore/command.rb
elsmore-0.1.2 lib/elsmore/command.rb
elsmore-0.1.1 lib/elsmore/command.rb