Add some debugging

This commit is contained in:
Alex Kotov 2023-09-30 01:33:59 +04:00
parent 19beb1901a
commit 3548d5995a
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08

View file

@ -12,7 +12,7 @@ $stdout.sync = true
def parse_command(line)
line = String(line).chomp
command = line[0...line.index(' ')].freeze
command = line[0...line.index(' ')].upcase.freeze
rest = line[command.length..].strip.freeze
[command, rest].freeze
end
@ -31,6 +31,7 @@ workdir = File.expand_path(workdir).freeze
config = Referator::Config.new workdir
footnotes = Referator::Footnotes.new config
stacktrace = nil
while (line = $stdin.gets)
begin
@ -39,6 +40,11 @@ while (line = $stdin.gets)
when 'EXIT'
success
exit
when 'PING'
success :pong
when 'STACKTRACE'
success stacktrace
stacktrace = nil
when 'REGISTER_FORMAT'
data = JSON.parse rest
config.formats.register(
@ -76,6 +82,7 @@ while (line = $stdin.gets)
raise 'Invalid command'
end
rescue => e
stacktrace = e.backtrace.map(&:freeze).freeze
failure e.detailed_message
end
end