Module: GreenHat::Shell::Reports

Defined in:
lib/greenhat/shell/reports.rb

Overview

Logs

Class Method Summary collapse

Class Method Details

.auto_complete(_list, word) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/greenhat/shell/reports.rb', line 22

def self.auto_complete(_list, word)
  matches = GreenHat::ShellHelper::Reports.auto_complete_list.select do |x|
    x.include? word
  end

  if matches.count > 1
    puts "#{'Report Options:'.pastel(:bright_blue)} #{matches.join(' ').pastel(:bright_green)}"

    Cli.common_substr(matches.map(&:to_s))
  elsif matches.count == 1
    matches.first
  end
end

.default(raw = []) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/greenhat/shell/reports.rb', line 48

def self.default(raw = [])
  list, flags, args = Args.parse(raw)

  # Collect Reporst to Run
  run_list = GreenHat::ShellHelper::Reports.list.select do |entry|
    list.include? File.basename(entry, '.rb')
  end

  run_list.uniq!

  run_list.each do |file|
    raw_args = list.reject { |x| file.include? x }
    GreenHat::ShellHelper::Reports.run(file: file, args: args, flags: flags, raw_args: raw_args)
  end
end

.ls(raw = []) ⇒ Object

Easy Show All



37
38
39
40
41
42
43
44
45
46
# File 'lib/greenhat/shell/reports.rb', line 37

def self.ls(raw = [])
  filter, _flags, _args = Args.parse(raw)

  list = GreenHat::ShellHelper::Reports.list
  list.select! { |x| x.include? filter.first } unless filter.blank?

  list.each do |x|
    puts "- #{File.basename(x, '.rb').pastel(:yellow)}"
  end
end