skippyPeanutButter/yaml_bot

View on GitHub
bin/yamlbot

Summary

Maintainability
Test Coverage
#!/usr/bin/env ruby

$LOAD_PATH.unshift(File.dirname(File.realpath(__dir__)) + '/../lib')

require 'optparse'
require 'yaml_bot'
require 'benchmark'

banner = <<~BANNER
  I am YamlBot feed me YAML!

BANNER

options = {}
parser = OptionParser.new do |opts|
  opts.banner = banner
  opts.banner += 'Usage: yamlbot -f yaml_file_to_validate ' \
                 '[-r path_to_rules_file]'

  opts.on('-r', '--rule-file rules',
          'The rules you will be evaluating your yaml against') do |rules|
    options[:rules] = rules
  end

  opts.on('-f', '--file file', 'The file to validate against') do |file|
    options[:file] = file
  end

  # opts.on('-c', '--no-color', 'Disable colored output') do
  #   options[:no_color] = true
  # end

  opts.on('-h', '--help', 'help') do
    puts parser
    exit
  end
end
parser.parse!

cli_bot = YamlBot::CLIBot.new(options)
result = 0

time = Benchmark.realtime do
  result = cli_bot.run
end

puts '----------------------------------------------'
puts "Scanning took #{time} seconds"

result