2005-07-07 14:22:47 +00:00
|
|
|
|
|
|
|
module Msf
|
|
|
|
module Ui
|
|
|
|
module Console
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# Console table display wrapper that allows for stylized tables
|
|
|
|
#
|
|
|
|
###
|
|
|
|
class Table < Rex::Ui::Text::Table
|
|
|
|
|
2005-11-15 15:11:43 +00:00
|
|
|
#
|
|
|
|
# Default table styles.
|
|
|
|
#
|
2005-07-07 14:22:47 +00:00
|
|
|
module Style
|
|
|
|
Default = 0
|
|
|
|
end
|
|
|
|
|
2005-11-15 15:11:43 +00:00
|
|
|
#
|
|
|
|
# Initializes a wrappered table with the supplied style and options.
|
|
|
|
#
|
2005-07-07 14:22:47 +00:00
|
|
|
def initialize(style, opts = {})
|
2005-07-07 23:11:03 +00:00
|
|
|
self.style = style
|
|
|
|
|
|
|
|
if (self.style == Style::Default)
|
2005-07-07 14:22:47 +00:00
|
|
|
opts['Indent'] = 3
|
2005-07-07 23:11:03 +00:00
|
|
|
if (!opts['Prefix'])
|
2005-07-10 08:36:53 +00:00
|
|
|
opts['Prefix'] = "\n"
|
2005-07-07 23:11:03 +00:00
|
|
|
end
|
|
|
|
if (!opts['Postfix'])
|
2005-07-14 20:18:36 +00:00
|
|
|
opts['Postfix'] = "\n"
|
2005-07-07 23:11:03 +00:00
|
|
|
end
|
2005-07-07 14:22:47 +00:00
|
|
|
|
|
|
|
super(opts)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2005-11-15 15:11:43 +00:00
|
|
|
#
|
|
|
|
# Print nothing if there are no rows if the style is default.
|
|
|
|
#
|
2005-07-07 23:11:03 +00:00
|
|
|
def to_s
|
|
|
|
if (style == Style::Default)
|
|
|
|
return '' if (rows.length == 0)
|
|
|
|
end
|
|
|
|
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
2005-11-15 15:11:43 +00:00
|
|
|
attr_accessor :style # :nodoc:
|
2005-07-07 23:11:03 +00:00
|
|
|
|
2005-07-07 14:22:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
2008-10-19 21:03:39 +00:00
|
|
|
end
|