class IRB::ExtendCommand::ShowSource

def bold(str)

def bold(str)
  Color.colorize(str, [:BOLD])
end

def execute(str = nil)

def execute(str = nil)
  unless str.is_a?(String)
    puts "Error: Expected a string but got #{str.inspect}"
    return
  end
  source = SourceFinder.new(@irb_context).find_source(str)
  if source
    show_source(source)
  else
    puts "Error: Couldn't locate a definition for #{str}"
  end
  nil
end

def show_source(source)

def show_source(source)
  file_content = IRB::Color.colorize_code(File.read(source.file))
  code = file_content.lines[(source.first_line - 1)...source.last_line].join
  content = <<~CONTENT
    #{bold("From")}: #{source.file}:#{source.first_line}
    #{code}
  CONTENT
  Pager.page_content(content)
end

def transform_args(args)

def transform_args(args)
  # Return a string literal as is for backward compatibility
  if args.empty? || string_literal?(args)
    args
  else # Otherwise, consider the input as a String for convenience
    args.strip.dump
  end
end