Class: HTMLProofer::CLI

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

Overview

The CLI is a class responsible of handling all the command line interface logic.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



9
10
11
# File 'lib/html_proofer/cli.rb', line 9

def initialize
  @options = {}
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/html_proofer/cli.rb', line 7

def options
  @options
end

Instance Method Details

#run(args = ARGV) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/html_proofer/cli.rb', line 13

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