Sha256: e5817874bb4b3c2200b6def8e94609841bf6c37233926870efa4505b1b1a3458

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

#!/usr/bin/env ruby

require 'simplabs/excellent'
require 'pathname'
require 'optparse'

options = {}

optparse = OptionParser.new do |opt|
  opt.banner = 'Usage: excellent [OPTIONS] <PATH1> [<PATH2> ...]'
  opt.on('--output', '-o [FILE]', 'Write HTML output to [FILE].') do |target|
    options[:output] = target
  end
  opt.on_tail('--help', '-h', 'Help') do
    puts optparse
    exit
  end
end

optparse.parse!

target   = options[:output]
paths    = ARGV.dup

if paths.empty?
  puts "\n  You must specify one or more directories to analyse, e.g.:\n"
  puts "\n    excellent lib/\n\n"
  exit 1
end

if target
  begin
    fileio = File.open(target, 'w+')
    formatter = Simplabs::Excellent::Formatters::Html.new(fileio)
  rescue Errno::ENOENT
    puts "\n  #{target} cannot be opened for writing. Specify a file name like so:\n"
    puts "\n    excellent -o excellent.html lib/\n\n"
  end
else
  formatter = Simplabs::Excellent::Formatters::Text.new
end

excellent = Simplabs::Excellent::Runner.new

begin
  excellent.check_paths(paths, formatter)
rescue ArgumentError
  puts "\n** Excellent cannot find the paths specified!\n\n"
  exit 1
end

exit 0

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
excellent-1.7.0 bin/excellent
excellent-1.6.0 bin/excellent