Class: VerifyRedirects::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/verify_redirects/cli.rb

Class Method Summary collapse

Class Method Details

.parse(argv:, name:) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/verify_redirects/cli.rb', line 7

def self.parse(argv:, name:)
  options = {}
  OptionParser.new do |parser|
    parser.banner = "Usage: #{name} --help"
    parser.default_argv = argv

    parser.on('--input=val0', String, "CSV file path (required) - must be a file with two columns: from_url, to_url (order doesn't matter)") do |string|
      options[:input] = string
    end

    parser.on('--output=val0', String, 'CSV output path (optional)') do |string|
      options[:output] = string
    end

    parser.on('--[no-]debug', 'Print debug output (default: false)') do |boolean|
      options[:debug] = boolean
    end

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

  options
end