Class: MetricFu::Cli::Helper

Inherits:
Object
  • Object
show all
Defined in:
lib/metric_fu/cli/helper.rb

Instance Method Summary collapse

Constructor Details

#initializeHelper

Returns a new instance of Helper.



14
15
16
# File 'lib/metric_fu/cli/helper.rb', line 14

def initialize
  @metric_fu = MetricFu::Run.new
end

Instance Method Details



32
33
34
# File 'lib/metric_fu/cli/helper.rb', line 32

def banner
  "MetricFu: A Fistful of code metrics"
end

#executable_nameObject



43
44
45
# File 'lib/metric_fu/cli/helper.rb', line 43

def executable_name
  "metric_fu"
end

#metricsObject



47
48
49
# File 'lib/metric_fu/cli/helper.rb', line 47

def metrics
  MetricFu::Metric.metrics.map(&:name).sort_by(&:to_s)
end

#process_options(argv = []) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/metric_fu/cli/helper.rb', line 51

def process_options(argv = [])
  options = MetricFu::Cli::MicroOptParse::Parser.new do |p|
    p.banner = banner
    p.version = version
    p.option :run, "Run all metrics with defaults", default: true
    metrics.each do |metric|
      p.option metric.to_sym, "Enables or disables #{metric}", default: true # , :value_in_set => [true, false]
    end
    p.option :open, "Open report in browser (if supported by formatter)", default: true
  end.process!(argv)
  options
end

#run(options = {}) ⇒ Object



18
19
20
21
# File 'lib/metric_fu/cli/helper.rb', line 18

def run(options = {})
  @metric_fu.run(options)
  complete
end

#shutdownObject



27
28
29
30
# File 'lib/metric_fu/cli/helper.rb', line 27

def shutdown
  out "\nShutting down. Bye"
  MetricFu::Cli.immediate_shutdown!
end

#usageObject



36
37
38
39
40
41
# File 'lib/metric_fu/cli/helper.rb', line 36

def usage
  <<-EOS
  #{banner}
  Use --help for help
  EOS
end

#versionObject



23
24
25
# File 'lib/metric_fu/cli/helper.rb', line 23

def version
  MetricFu::VERSION
end