Sha256: f41ef6dfcbe6ad5104985d1c29018308084e749c9ccc4752de2a6b912a86df39

Contents?: true

Size: 915 Bytes

Versions: 3

Compression:

Stored size: 915 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

# for dev purposes
require 'bundler/setup' if ENV['URL_FINDER_GEM_DEV']

require 'url_finder'
require 'optparse'

options = {}
OptionParser.new do |parser|
  parser.banner = 'Usage: url_finder --help'
  parser.default_argv = ARGV

  parser.on('--file=/path/to/file', String, 'Input file') do |string|
    options[:file] = string
  end

  parser.on('--format=file_format', String, 'Input format (html, markdown, sitemap.xml, string)') do |string|
    options[:format] = string
  end

  parser.on('-v', '--version', 'Print version') do
    puts "UrlFinder version #{UrlFinder::VERSION}"
    exit
  end

  parser.on('-h', '--help', 'How to use') do
    puts parser
    exit
  end
end.parse!

file = options.fetch(:file) { raise(ArgumentError, '--file is required') }
file_format = options[:format]

UrlFinder.from_file(file, file_format).each do |url|
  puts url
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
url_finder-0.2.2 exe/url_finder
url_finder-0.2.1 exe/url_finder
url_finder-0.2.0 exe/url_finder