Sha256: 411cdbb40e36ba72e4775549bd4d1118f2039b884f32d6b31d83efa1bc20b979

Contents?: true

Size: 858 Bytes

Versions: 2

Compression:

Stored size: 858 Bytes

Contents

# frozen_string_literal: true

require 'optparse'

module VerifyRedirects
  class CLI
    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') 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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
verify_redirects-0.2.0 lib/verify_redirects/cli.rb
verify_redirects-0.1.1 lib/verify_redirects/cli.rb