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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/puppet-lint/bin.rb', line 8
def run
help = " Puppet-lint\n\n Basic Command Line Usage:\n puppet-lint [OPTIONS] [PATH]\n\n PATH The path to the Puppet manifest.\n\n Options:\n EOHELP\n\n opts = OptionParser.new do |opts|\n opts.banner = help\n\n opts.on(\"--version\", \"Display current version.\") do\n puts \"Puppet-lint \" + PuppetLint::VERSION\n return 0\n end\n\n opts.on('--with-context', 'Show where in the manifest the problem is') do\n PuppetLint.configuration.with_context = true\n end\n\n opts.on(\"--with-filename\", \"Display the filename before the warning\") do\n PuppetLint.configuration.with_filename = true\n end\n\n opts.on(\"--fail-on-warnings\", \"Return a non-zero exit status for warnings.\") do\n PuppetLint.configuration.fail_on_warnings = true\n end\n\n opts.on(\"--error-level LEVEL\", [:all, :warning, :error], \"The level of error to return.\", \"(warning, error, all)\") do |el|\n PuppetLint.configuration.error_level = el\n end\n\n opts.on(\"--log-format FORMAT\",\n \"Change the log format.\", \"Overrides --with-filename.\",\n \"The following placeholders can be used:\",\n \"%{filename} - Filename without path.\",\n \"%{path} - Path as provided.\",\n \"%{fullpath} - Full path.\",\n \"%{linenumber} - Line number.\",\n \"%{kind} - The kind of message.\",\n \" - (warning, error)\",\n \"%{KIND} - Uppercase version of %{kind}\",\n \"%{check} - Name of the check.\",\n \"%{message} - The message.\"\n ) do |format|\n PuppetLint.configuration.log_format = format\n end\n\n opts.separator \"\"\n opts.separator \" Disable checks:\"\n\n PuppetLint.configuration.checks.each do |check|\n opts.on(\"--no-\#{check}-check\", \"Skip the \#{check} check\") do\n PuppetLint.configuration.send(\"disable_\#{check}\")\n end\n end\n\n opts.load('/etc/puppet-lint.rc')\n\n if ENV['HOME']\n opts.load(File.expand_path('~/.puppet-lint.rc'))\n if opts.load(File.expand_path('~/.puppet-lintrc'))\n $stderr.puts 'Depreciated: Found ~/.puppet-lintrc instead of ~/.puppet-lint.rc'\n end\n end\n\n opts.load('.puppet-lint.rc')\n if opts.load('.puppet-lintrc')\n $stderr.puts 'Depreciated: Read .puppet-lintrc instead of .puppet-lint.rc'\n end\n end\n\n begin\n opts.parse!(@args)\n rescue OptionParser::InvalidOption\n puts \"puppet-lint: \#{$!.message}\"\n puts \"puppet-lint: try 'puppet-lint --help' for more information\"\n return 1\n end\n\n if @args[0].nil?\n puts \"puppet-lint: no file specified\"\n puts \"puppet-lint: try 'puppet-lint --help' for more information\"\n return 1\n end\n\n begin\n path = @args[0]\n if File.directory?(path)\n path = Dir.glob(\"\#{path}/**/*.pp\")\n else\n path = @args\n end\n\n return_val = 0\n path.each do |f|\n l = PuppetLint.new\n l.file = f\n l.run\n if l.errors? or (l.warnings? and PuppetLint.configuration.fail_on_warnings)\n return_val = 1\n end\n end\n return return_val\n\n rescue PuppetLint::NoCodeError\n puts \"puppet-lint: no file specified or specified file does not exist\"\n puts \"puppet-lint: try 'puppet-lint --help' for more information\"\n return 1\n end\nend\n"
|