Module: Byebug::CommandFunctions

Defined in:
lib/byebug/command.rb

Instance Method Summary collapse

Instance Method Details

#find(subcmds, param) ⇒ Object

Find param in subcmds.

the subcommands.

Parameters:

  • is

    downcased and can be abbreviated to the minimum length listed in



23
24
25
26
27
28
29
30
31
32
# File 'lib/byebug/command.rb', line 23

def find(subcmds, param)
  param.downcase!
  for try_subcmd in subcmds do
    if (param.size >= try_subcmd.min) and
        (try_subcmd.name[0..param.size-1] == param)
      return try_subcmd
    end
  end
  return nil
end

#format_subcmds(subcmds) ⇒ Object

Build formatted list of subcmds



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/byebug/command.rb', line 37

def format_subcmds(subcmds)
  cmd_name = self.class.names.join("|")
  s = "\n"                                     \
      "--\n"                                   \
      "List of \"#{cmd_name}\" subcommands:\n" \
      "--\n"
  for subcmd in subcmds do
    s += "#{cmd_name} #{subcmd.name} -- #{subcmd.short_help}\n"
  end
  return s
end

#pad_with_dots(string) ⇒ Object

Pad a string with dots at the end to fit :width setting



11
12
13
14
15
# File 'lib/byebug/command.rb', line 11

def pad_with_dots(string)
  if string.size > Command.settings[:width]
    string[Command.settings[:width]-3 .. -1] = "..."
  end
end