Sha256: 7a0571205b5d5a7dbd6d858ba78e7d89db8c8c01e351a695edc8b1e518e0a862

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

require 'optparse'

module VerifyUrls
  class CLI
    def self.parse(argv:)
      options = {}
      OptionParser.new do |parser|
        parser.banner = 'Usage: verify_urls --help'
        parser.default_argv = argv

        parser.on('--file=README.md', String, 'The file that contains the URLs to verify.') do |string|
          options[:file] = string
        end

        parser.on('--format=markdown', String, "The file format (optional) - one of markdown, html, csv (if none given we'll try to infer it from the file path).") do |string|
          options[:format] = string
        end

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

        parser.on('--[no-]error-failed', 'Exit with non-zero status if any URL(s) failed.') do |boolean|
          options[:error_failed] = boolean
        end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
verify_urls-0.3.2 lib/verify_urls/cli.rb
verify_urls-0.3.1 lib/verify_urls/cli.rb
verify_urls-0.3.0 lib/verify_urls/cli.rb
verify_urls-0.2.0 lib/verify_urls/cli.rb
verify_urls-0.1.0 lib/verify_urls/cli.rb