Method: Rex::Ui::Text::DispatcherShell::CommandDispatcher#help_to_s
- Defined in:
- lib/rex/ui/text/dispatcher_shell.rb
#help_to_s(opts = {}) ⇒ Object
Return a pretty, user-readable table of commands provided by this dispatcher. The command column width can be modified by passing in :command_width.
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'lib/rex/ui/text/dispatcher_shell.rb', line 237 def help_to_s(opts={}) # If this dispatcher has no commands, we can't do anything useful. return "" if commands.nil? or commands.length == 0 # Display the commands tbl = Rex::Text::Table.new( 'Header' => "#{self.name} Commands", 'Indent' => opts['Indent'] || 4, 'Columns' => [ 'Command', 'Description' ], 'ColProps' => { 'Command' => { 'Width' => opts[:command_width] } }) commands.sort.each { |c| tbl << c } return "\n" + tbl.to_s + "\n" end |