Sha256: 747653f3954227f70232259d83a8a5a47f3dfe83ed77390110e3bed1f07300fe

Contents?: true

Size: 867 Bytes

Versions: 7

Compression:

Stored size: 867 Bytes

Contents

require 'thor'
require 'fukuzatsu'

module Fukuzatsu

  class CLI < Thor

    desc_text = "Formats are text (default, to STDOUT), html, and csv. "
    desc_text << "Example: fuku check foo/ -f html"

    desc "check PATH_TO_FILE [-f FORMAT] [-t MAX_COMPLEXITY_ALLOWED]", desc_text
    method_option :format, :type => :string, :default => 'text', :aliases => "-f"
    method_option :threshold, :type => :numeric, :default => 0, :aliases => "-t"

    def check(path="./")
      parser = Fukuzatsu::Parser.new(
        path,
        formatter,
        options['threshold']
      )
      parser.parse_files
      parser.report
    end

    default_task :check

    private

    def formatter
      case options['format']
      when 'html'
        Formatters::Html
      when 'csv'
        Formatters::Csv
      else
        Formatters::Text
      end
    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fukuzatsu-1.0.6 lib/fukuzatsu/cli.rb
fukuzatsu-1.0.5 lib/fukuzatsu/cli.rb
fukuzatsu-1.0.4 lib/fukuzatsu/cli.rb
fukuzatsu-1.0.3 lib/fukuzatsu/cli.rb
fukuzatsu-1.0.2 lib/fukuzatsu/cli.rb
fukuzatsu-1.0.1 lib/fukuzatsu/cli.rb
fukuzatsu-1.0.0 lib/fukuzatsu/cli.rb