Class: IRB::ExtendCommand::ShowCmds
Instance Attribute Summary
Attributes inherited from Nop
Instance Method Summary collapse
Methods inherited from Nop
category, description, execute, #initialize, #irb
Constructor Details
This class inherits a constructor from IRB::ExtendCommand::Nop
Instance Method Details
#execute(*args) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/irb/cmd/show_cmds.rb', line 14 def execute(*args) commands_info = IRB::ExtendCommandBundle.all_commands_info commands_grouped_by_categories = commands_info.group_by { |cmd| cmd[:category] } longest_cmd_name_length = commands_info.map { |c| c[:display_name] }.max { |a, b| a.length <=> b.length }.length output = StringIO.new commands_grouped_by_categories.each do |category, cmds| output.puts Color.colorize(category, [:BOLD]) cmds.each do |cmd| output.puts " #{cmd[:display_name].to_s.ljust(longest_cmd_name_length)} #{cmd[:description]}" end output.puts end puts output.string nil end |