class Specifier::CLI

Used when interacting with the suite from the command line interface (CLI).

Usage:

cli = Specifier::CLI.new
cli.parse

Constants

Public Instance Methods

parse(items = ARGV) click to toggle source
# File lib/specifier/cli.rb, line 13
def parse(items = ARGV)
  config = Slop.parse(items) do |options|
    options.banner = BANNER

    options.on('-h', '--help', 'help') { return help(options) }
    options.on('-v', '--version', 'version') { return version }

    options.string('-f', '--formatter', 'formatter', default: Specifier::Formatter::DEFAULT)
  end

  run(config)
end

Private Instance Methods

help(options) click to toggle source
# File lib/specifier/cli.rb, line 28
def help(options)
  Specifier.logger.log(String(options))
end
run(options) click to toggle source
# File lib/specifier/cli.rb, line 36
def run(options)
  Specifier.config.formatter = options[:formatter]

  paths = Set.new
  options.arguments.each do |argument|
    Find.find(argument) do |path|
      paths << path if path.match?(/\A(.*).rb\Z/)
    end
  end
  Runner.new(paths: paths).run
end
version() click to toggle source
# File lib/specifier/cli.rb, line 32
def version
  Specifier.logger.log(String(VERSION))
end