exe/chutney in chutney-3.6.0 vs exe/chutney in chutney-3.7.0
- old
+ new
@@ -7,10 +7,11 @@
require 'chutney/formatter/pie_formatter'
require 'chutney/formatter/rainbow_formatter'
require 'optparse'
formatters = Set.new
+quiet = false
# rubocop:disable Metrics/BlockLength
OptionParser.new do |opts|
opts.banner = 'Usage: chutney [files]'
opts.on('-f',
@@ -19,18 +20,24 @@
raise 'No Such Formatter' unless %w[JSONFormatter PieFormatter RainbowFormatter].include? formatter
formatters << formatter
end
+ opts.on('-q',
+ '--quiet',
+ 'Disable chutney usage warnings. Does not affect the output of the formatters.') do
+ quiet = true
+ end
+
opts.on('-v', '--version', 'Display the version.') do
puts Chutney::VERSION
exit
end
opts.on('-l',
'--linters',
- 'List the linter status by this configuration and exit') do
+ 'List the linter status by this configuration and exit.') do
pastel = Pastel.new
chutney_config = Chutney::ChutneyLint.new.configuration
max_name_length = chutney_config.keys.map(&:length).max + 1
chutney_config.each do |linter, value|
print pastel.cyan(linter.ljust(max_name_length))
@@ -41,18 +48,37 @@
puts pastel.red('disabled')
end
end
exit
end
+
+ opts.on('--init',
+ 'Install a `chutney.yml` configuration file.') do
+ config_dest = if File.exist?('config') && File.directory?('config')
+ 'config'
+ else
+ '.'
+ end
+ config_path = File.join(config_dest, 'chutney.yml')
+ default_path = Chutney::ChutneyLint.new.configuration.default_configuration_path
+ if File.exist?(config_path)
+ puts "#{config_path} already exists - remove it first if you want to overwrite."
+ else
+ FileUtils.cp(default_path, config_path)
+ puts "#{config_path} created."
+ end
+ exit
+ end
end.parse!
# rubocop:enable Metrics/BlockLength
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)
+linter.configuration.quiet! if quiet
report = linter.analyse
formatters.each do |formatter|
f = Object.const_get("Chutney::#{formatter}").new
f.results = report