#!/usr/bin/env ruby require 'chutney' require 'chutney/formatter' require 'chutney/formatter/json_formatter' require 'chutney/formatter/pie_formatter' require 'chutney/formatter/rainbow_formatter' require 'optparse' formatters = Set.new OptionParser.new do |opts| opts.banner = 'Usage: chutney [files]' opts.on('-f', '--format [formatter]', 'One of JSONFormatter, PieFormatter or RainbowFormatter (default).') do |formatter| raise 'No Such Formatter' unless %w[JSONFormatter PieFormatter RainbowFormatter].include? formatter formatters << formatter end end.parse! formatters << 'RainbowFormatter' if formatters.empty? files = ARGV.map { |pattern| Dir.glob(pattern) }.flatten files = Dir.glob('features/**/*.feature') if ARGV.empty? linter = Chutney::ChutneyLint.new(*files) report = linter.analyse formatters.each do |formatter| f = Object.const_get("Chutney::#{formatter}").new f.results = report f.format end basic_formatter = Chutney::Formatter.new basic_formatter.results = report if basic_formatter.files_with_issues.empty? exit(true) else exit(false) end