2017-11-01 15:21:41 +00:00
|
|
|
require "option_parser"
|
|
|
|
require "./ameba"
|
|
|
|
|
2017-11-13 21:20:22 +00:00
|
|
|
files, formatter, config_path = nil, nil, nil
|
2017-11-06 08:38:17 +00:00
|
|
|
|
2017-11-01 15:21:41 +00:00
|
|
|
OptionParser.parse(ARGV) do |parser|
|
2017-11-13 21:20:22 +00:00
|
|
|
parser.banner = "Usage: ameba [options] [file1 file2 ...]"
|
2017-11-01 15:21:41 +00:00
|
|
|
|
|
|
|
parser.on("-v", "--version", "Print version") do
|
|
|
|
puts Ameba::VERSION
|
|
|
|
exit 0
|
|
|
|
end
|
|
|
|
|
|
|
|
parser.on("-h", "--help", "Show this help") do
|
|
|
|
puts parser
|
|
|
|
exit 0
|
|
|
|
end
|
2017-11-06 08:38:17 +00:00
|
|
|
|
|
|
|
parser.on("-s", "--silent", "Disable output") do
|
2017-11-13 21:20:22 +00:00
|
|
|
formatter = Ameba::Formatter::BaseFormatter.new
|
|
|
|
end
|
|
|
|
|
|
|
|
# parser.on("-f FORMATTER", "--format FORMATTER", "Specify formatter") do |f|
|
|
|
|
# end
|
|
|
|
|
|
|
|
parser.on("-c PATH", "--config PATH", "Specify configuration file") do |f|
|
|
|
|
config_path = f
|
|
|
|
end
|
|
|
|
|
|
|
|
parser.unknown_args do |f|
|
|
|
|
files = f if f.any?
|
2017-11-06 08:38:17 +00:00
|
|
|
end
|
2017-11-01 15:21:41 +00:00
|
|
|
end
|
|
|
|
|
2017-11-13 21:20:22 +00:00
|
|
|
config = Ameba::Config.load config_path
|
|
|
|
config.formatter = formatter
|
|
|
|
config.files = files
|
2017-11-06 08:38:17 +00:00
|
|
|
|
2017-11-13 21:20:22 +00:00
|
|
|
exit(1) unless Ameba.run(config).success?
|