CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/msf/ui/console/table.rb
Views: 11623
1
# -*- coding: binary -*-
2
3
module Msf
4
module Ui
5
module Console
6
7
###
8
#
9
# Console table display wrapper that allows for stylized tables
10
#
11
###
12
class Table < Rex::Text::Table
13
14
#
15
# Default table styles.
16
#
17
module Style
18
Default = 0
19
end
20
21
def self.new(*args, &block)
22
style, opts = args
23
24
if style == Style::Default
25
opts['Indent'] = 3
26
if (!opts['Prefix'])
27
opts['Prefix'] = "\n"
28
end
29
if (!opts['Postfix'])
30
opts['Postfix'] = "\n"
31
end
32
end
33
34
instance = super(opts, &block)
35
if style == Style::Default
36
instance.extend(DefaultStyle)
37
end
38
instance
39
end
40
41
module DefaultStyle
42
#
43
# Print nothing if there are no rows if the style is default.
44
#
45
def to_s
46
return '' if (rows.length == 0)
47
48
super
49
end
50
end
51
end
52
end
53
end
54
end
55
56