class DEBUGGER__::Session
def show_help arg = nil
def show_help arg = nil instructions = (DEBUGGER__.commands.keys + DEBUGGER__.commands.values).uniq print_instructions = proc do |desc| desc.split("\n").each do |line| next if line.start_with?(" ") # workaround for step back formatted_line = line.gsub(/[\[\]\*]/, "").strip instructions.each do |inst| if formatted_line.start_with?("`#{inst}") desc.sub!(line, colorize(line, [:CYAN, :BOLD])) end end end @ui.puts desc end print_category = proc do |cat| @ui.puts "\n" @ui.puts colorize("### #{cat}", [:GREEN, :BOLD]) @ui.puts "\n" end DEBUGGER__.helps.each { |cat, cs| # categories if arg.nil? print_category.call(cat) else cs.each { |ws, _| if ws.include?(arg) print_category.call(cat) break end } end # instructions cs.each { |ws, desc| if arg.nil? || ws.include?(arg) print_instructions.call(desc.dup) return if arg end } } @ui.puts "not found: #{arg}" if arg end