Method: Mihari::Commands::Validator.included

Defined in:
lib/mihari/commands/validator.rb

.included(thor) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/mihari/commands/validator.rb', line 8

def self.included(thor)
  thor.class_eval do
    desc "rule [PATH]", "Validate format of a rule file"
    def rule(path)
      rule = load_rule(path)

      begin
        validate_rule! rule
        Mihari.logger.info "Valid format. The input is parsed as the following:\n#{rule.data.to_yaml}"
      rescue RuleValidationError
        nil
      end
    end
  end
end