#!/usr/bin/env ruby require 'scripted' require 'optparse' require 'set' config = Scripted.configure groups = Set.new parser = OptionParser.new do |opts| opts.on_tail("-h", "--help", "Shows the available options") do puts opts exit end opts.on_tail("-v", "--version", "Shows the version") do puts Scripted::VERSION exit end opts.on("-r", "--require a,b", Array, "Which files should be loaded (defaults to `scripted.rb`)") do |file_names| config.config_file(*file_names) end opts.on("-g", "--group a,b", Array, "Which groups to run (defaults to `:default`)") do |group_names| groups += group_names end opts.on("-f", "--format name", "Specify a formatter (defaults to `default`)") do |formatter| config.formatter formatter end opts.on("-o", "--out output", "Specify the output of the previously specified formatter") do |out| config.out out end opts.on("-c", "--[no-]color", "Use color in formatters? (defaults to yes)") do |color| config.color = color end opts.on("-I PATH", "Add a directory to your load path") do |load_path| $LOAD_PATH.unshift(load_path) end end begin parser.parse! config.with_default_config_file! config.load_files rescue OptionParser::InvalidOption => error puts error puts "" puts parser exit 1 rescue Scripted::ConfigurationError => error puts "#{error} at #{error.backtrace.first}" exit 1 end begin Scripted.run config, *groups rescue Scripted::RunningFailed => error puts error exit 1 end