Module: GreenHat::Shell::Process

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

Overview

Logs

Class Method Summary collapse

Class Method Details

.filter(raw = {}) ⇒ Object



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

def self.filter(raw = {})
  # Argument Parsing
  files, flags, args = Args.parse(raw)

  # Prepare Log List
  file_list = ShellHelper.prepare_list(files, GreenHat::Ps.things)

  results = ShellHelper.filter_start(file_list, flags, args)

  # Check Search Results
  if results.instance_of?(Hash) && results.values.flatten.empty?
    puts 'No results'.pastel(:red)
  else
    # This causes the key 'colorized' output to also be included
    ShellHelper.show(results.to_a.compact.flatten, flags)
  end
end

.filter_helpObject



33
34
35
# File 'lib/greenhat/shell/process.rb', line 33

def self.filter_help
  ShellHelper::Filter.help
end

.helpObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/greenhat/shell/process.rb', line 13

def self.help
  puts "\u2500".pastel(:cyan) * 22
  puts "#{'Process'.pastel(:yellow)} -  ps helper"
  puts "\u2500".pastel(:cyan) * 22

  ShellHelper.common_opts

  puts 'Command Summary'.pastel(:blue)
  puts '  ps'.pastel(:green)
  puts '    Raw `ps`'
  puts
  puts '  filter'.pastel(:green)
  puts "    Key/Field Filtering.  See #{'filter_help'.pastel(:blue)}"
  puts '    Examples'
  puts '      filter --sort=mem --reverse'.pastel(:green)
  puts '      filter --user=gitlab'.pastel(:green)

  puts
end

.lsObject

Easy Show All Filter –archive



9
10
11
# File 'lib/greenhat/shell/process.rb', line 9

def self.ls
  help
end

.ps(raw = {}) ⇒ Object



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

def self.ps(raw = {})
  # Extract Args
  files_list, flags, _args = Args.parse(raw)

  # Collect Files
  files = ShellHelper.files(files_list, GreenHat::Ps.things, flags)

  # Output
  ShellHelper.file_output(files, flags)
end