class Byebug::VarConstantCommand

def description

def description
  %{
    v[ar] co[nst] <object>\t\tshow constants of object
  }
end

def execute

def execute
  obj = debug_eval(@match.post_match)
  if obj.kind_of? Module
    constants = debug_eval("#{@match.post_match}.constants")
    constants.sort!
    for c in constants
      next if c =~ /SCRIPT/
      value = obj.const_get(c) rescue "ERROR: #{$!}"
      print " %s => %p\n", c, value
    end
  else
    print "Should be Class/Module: %s\n", @match.post_match
  end
end

def names

def names
  %w(var)
end

def regexp

def regexp
  /^\s*v(?:ar)?\s+co(?:nst(?:ant)?)?\s+/
end