Skip to content

Commit

Permalink
Support adding document to registered commands
Browse files Browse the repository at this point in the history
  • Loading branch information
st0012 committed Jul 20, 2022
1 parent 5f5bbdc commit 9c22681
Show file tree
Hide file tree
Showing 3 changed files with 308 additions and 275 deletions.
1 change: 1 addition & 0 deletions exe/rdbg
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ when :start
exec(env, cmd, *ARGV)

when :attach
require_relative "../lib/debug/session"
require_relative "../lib/debug/client"
::DEBUGGER__::CONFIG.set_config(**config)

Expand Down
27 changes: 5 additions & 22 deletions lib/debug/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -471,32 +471,15 @@ def self.create_unix_domain_socket_name(base_dir = unix_domain_socket_dir)

def self.parse_help
helps = Hash.new{|h, k| h[k] = []}
desc = cat = nil
cmds = Hash.new

File.read(File.join(__dir__, 'session.rb'), encoding: Encoding::UTF_8).each_line do |line|
case line
when /\A\s*### (.+)/
cat = $1
break if $1 == 'END'
when /\A\s*register_command (.+)/
next unless cat
next unless desc
ws = $1.split(/,\s*/).map{|e| e.gsub('\'', '')}
helps[cat] << [ws, desc]
desc = nil
max_w = ws.max_by{|w| w.length}
ws.each{|w|
cmds[w] = max_w
}
when /\A\s+# (\s*\*.+)/
if desc
desc << "\n" + $1
else
desc = $1
end
DEBUGGER__::Session::COMMAND_SET.values.uniq.each do |command|
command.names.each do |name|
cmds[name] = command.name
end
helps[command.category] << [command.names, command.doc]
end

@commands = cmds
@helps = helps
end
Expand Down
Loading

0 comments on commit 9c22681

Please sign in to comment.