File: cli.rb

package info (click to toggle)
ruby-html-proofer 5.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,524 kB
  • sloc: ruby: 4,389; sh: 8; makefile: 4; javascript: 1; php: 1
file content (28 lines) | stat: -rw-r--r-- 677 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

module HTMLProofer
  # The CLI is a class responsible of handling all the command line interface
  # logic.
  class CLI
    attr_reader :options

    def initialize
      @options = {}
    end

    def run(args = ARGV)
      @options, path = HTMLProofer::Configuration.new.parse_cli_options(args)

      paths = path.split(",")

      if @options[:as_links]
        links = path.split(",").map(&:strip)
        HTMLProofer.check_links(links, @options).run
      elsif File.directory?(paths.first)
        HTMLProofer.check_directories(paths, @options).run
      else
        HTMLProofer.check_file(path, @options).run
      end
    end
  end
end