dbg.lua 808 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. local skynet = require "skynet"
  2. local cmd = { ... }
  3. local function format_table(t)
  4. local index = {}
  5. for k in pairs(t) do
  6. table.insert(index, k)
  7. end
  8. table.sort(index)
  9. local result = {}
  10. for _,v in ipairs(index) do
  11. table.insert(result, string.format("%s:%s",v,tostring(t[v])))
  12. end
  13. return table.concat(result,"\t")
  14. end
  15. local function dump_line(key, value)
  16. if type(value) == "table" then
  17. print(key, format_table(value))
  18. else
  19. print(key,tostring(value))
  20. end
  21. end
  22. local function dump_list(list)
  23. local index = {}
  24. for k in pairs(list) do
  25. table.insert(index, k)
  26. end
  27. table.sort(index)
  28. for _,v in ipairs(index) do
  29. dump_line(v, list[v])
  30. end
  31. end
  32. skynet.start(function()
  33. local list = skynet.call(".launcher","lua", table.unpack(cmd))
  34. if list then
  35. dump_list(list)
  36. end
  37. skynet.exit()
  38. end)