lib/scss_lint/cli.rb in scss-lint-0.13.0 vs lib/scss_lint/cli.rb in scss-lint-0.14.0

- old
+ new

@@ -55,10 +55,14 @@ opts.on('-e', '--exclude file,...', Array, 'List of file names to exclude') do |files| @options[:excluded_files] = files end + opts.on('-f', '--format Formatter', 'Specify how to display lints', String) do |format| + set_output_format(format) + end + opts.on('-i', '--include-linter linter,...', Array, 'Specify which linters you want to run') do |linters| @options[:included_linters] = linters end @@ -76,14 +80,10 @@ end opts.on_tail('-v', '--version', 'Show version') do print_version opts.program_name, VERSION end - - opts.on('--xml', 'Output the results in XML format') do - @options[:reporter] = SCSSLint::Reporter::XMLReporter - end end end def run runner = Runner.new(@config) @@ -171,9 +171,16 @@ sorted_lints = lints.sort_by { |l| [l.filename, l.line] } reporter = @options.fetch(:reporter, Reporter::DefaultReporter) .new(sorted_lints) output = reporter.report_lints print output if output + end + + def set_output_format(format) + @options[:reporter] = SCSSLint::Reporter.const_get(format + 'Reporter') + rescue NameError + puts "Invalid output format specified: #{format}" + halt :config end def print_linters puts 'Installed linters:'