Class: Glossarist::CLI::ValidateCommand

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

Instance Method Summary collapse

Constructor Details

#initialize(path, options) ⇒ ValidateCommand

Returns a new instance of ValidateCommand.



9
10
11
12
# File 'lib/glossarist/cli/validate_command.rb', line 9

def initialize(path, options)
  @path = path
  @options = options
end

Instance Method Details

#runObject



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

def run
  text_output = @options[:format] == "text"
  validator = DatasetValidator.new(on_progress: text_output ? method(:print_progress) : nil)
  result = validator.validate(
    @path,
    strict: @options[:strict],
    reference_path: @options[:reference_path],
  )

  $stderr.print "\r#{' ' * 60}\r" if text_output
  report(result)
  exit(1) unless result.errors.empty? && !strict_failure?(result)
end