Sha256: d1c85d48bcf38c7e02d28f3ab646b6388d7405947579dedb45e48730841a18aa
Contents?: true
Size: 1.47 KB
Versions: 1
Compression:
Stored size: 1.47 KB
Contents
# frozen_string_literal: true require "optparse" require "rubocop" module Slimembedcop # Command line interface for Slimembedcop. class Cli class << self DEFAULT_CONFIG_PATH = File.expand_path("../default.yml", __dir__) DEFAULT_PATH_PATTERNS = %w[**/*.slim].freeze def run(argv) options = parse_options!(argv) formatter = ::RuboCop::Formatter::ProgressFormatter.new($stdout, color: options[:color]) config = ConfigGenerator.run(DEFAULT_CONFIG_PATH, options[:forced_config_path]) paths = PathFinder.run(DEFAULT_PATH_PATTERNS, config.for_all_cops["Exclude"], argv) offenses = Runner.run(paths, formatter, config, options[:autocorrect]) exit(offenses.empty? ? 0 : 1) end private def parse_options!(argv) options = {} parser = ::OptionParser.new parser.banner = "Usage: slimembedcop [options] [file1, file2, ...]" parser.version = VERSION parser.on("-a", "--autocorrect", "Autocorrect offenses.") do p "autocorrect" options[:autocorrect] = true end parser.on("-c", "--config=", "Specify configuration file. (default: #{DEFAULT_CONFIG_PATH} or .rubocop.yml)") do |file_path| options[:forced_config_path] = file_path end parser.on("--[no-]color", "Force color output on or off.") do |value| options[:color] = value end parser.parse!(argv) options end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
slimembedcop-0.1.0 | lib/slimembedcop/cli.rb |