Class: Onceover::CodeQuality::CLI

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

Class Method Summary collapse

Class Method Details

.commandObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/onceover/codequality/cli.rb', line 7

def self.command
  @cmd ||= Cri::Command.define do
    name 'codequality'
    usage 'codequality [--no-lint] [--no-syntax]'
    summary "Code Quality checking for onceover"
    description "Check files in your Control Repository for Lint and Syntax errors\n    DESCRIPTION\n  \n    option :l, :no_lint, 'Do not check for lint errors', :argument => :optional\n    option :x, :no_syntax, 'Do not check for syntax errors', :argument => :optional\n\n    run do |opts, args, cmd|\n      no_lint = opts[:no_lint] || false\n      no_syntax = opts[:no_syntax] || false\n      status = true\n      if ! no_lint\n        logger.info \"Checking for lint...\"\n        if ! Onceover::CodeQuality::Lint.puppet\n          status = false\n          logger.error \"Lint test failed, see previous errors\"\n        end\n      end\n\n      if ! no_syntax\n        logger.info \"Checking syntax...\"\n        if ! Onceover::CodeQuality::Syntax.puppet\n          status = false\n          logger.error \"Syntax test failed, see previous errors\"\n        end\n      end\n\n      if status\n        logger.info \"Code Quality tests passed, have a nice day\"\n      else\n        logger.error \"Code Quality tests failed, see previous error\"\n        exit 1\n      end\n    end\n  end\nend\n"