Software / code / prosody
Comparison
plugins/mod_admin_shell.lua @ 12224:2b348d65cd69
mod_admin_shell: Add help section about customizing table columns
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 28 Jan 2022 20:39:13 +0100 |
| parent | 12209:3fe2e5da05c3 |
| child | 12225:e9f34a04067e |
comparison
equal
deleted
inserted
replaced
| 12223:a68f1617721b | 12224:2b348d65cd69 |
|---|---|
| 200 end | 200 end |
| 201 end); | 201 end); |
| 202 | 202 |
| 203 -- Console commands -- | 203 -- Console commands -- |
| 204 -- These are simple commands, not valid standalone in Lua | 204 -- These are simple commands, not valid standalone in Lua |
| 205 | |
| 206 local available_columns; --forward declaration so it is reachable from the help | |
| 205 | 207 |
| 206 function commands.help(session, data) | 208 function commands.help(session, data) |
| 207 local print = session.print; | 209 local print = session.print; |
| 208 local section = data:match("^help (%w+)"); | 210 local section = data:match("^help (%w+)"); |
| 209 if not section then | 211 if not section then |
| 222 print [[port - Commands to manage ports the server is listening on]] | 224 print [[port - Commands to manage ports the server is listening on]] |
| 223 print [[dns - Commands to manage and inspect the internal DNS resolver]] | 225 print [[dns - Commands to manage and inspect the internal DNS resolver]] |
| 224 print [[xmpp - Commands for sending XMPP stanzas]] | 226 print [[xmpp - Commands for sending XMPP stanzas]] |
| 225 print [[debug - Commands for debugging the server]] | 227 print [[debug - Commands for debugging the server]] |
| 226 print [[config - Reloading the configuration, etc.]] | 228 print [[config - Reloading the configuration, etc.]] |
| 229 print [[columns - Information about customizing session listings]] | |
| 227 print [[console - Help regarding the console itself]] | 230 print [[console - Help regarding the console itself]] |
| 228 elseif section == "c2s" then | 231 elseif section == "c2s" then |
| 229 print [[c2s:show(jid, columns) - Show all client sessions with the specified JID (or all if no JID given)]] | 232 print [[c2s:show(jid, columns) - Show all client sessions with the specified JID (or all if no JID given)]] |
| 230 print [[c2s:show_tls(jid) - Show TLS cipher info for encrypted sessions]] | 233 print [[c2s:show_tls(jid) - Show TLS cipher info for encrypted sessions]] |
| 231 print [[c2s:count() - Count sessions without listing them]] | 234 print [[c2s:count() - Count sessions without listing them]] |
| 307 print [[!old!new! - repeat the last command, but with 'old' replaced by 'new']] | 310 print [[!old!new! - repeat the last command, but with 'old' replaced by 'new']] |
| 308 print [[]] | 311 print [[]] |
| 309 print [[For those well-versed in Prosody's internals, or taking instruction from those who are,]] | 312 print [[For those well-versed in Prosody's internals, or taking instruction from those who are,]] |
| 310 print [[you can prefix a command with > to escape the console sandbox, and access everything in]] | 313 print [[you can prefix a command with > to escape the console sandbox, and access everything in]] |
| 311 print [[the running server. Great fun, but be careful not to break anything :)]] | 314 print [[the running server. Great fun, but be careful not to break anything :)]] |
| 315 elseif section == "columns" then | |
| 316 print [[The columns shown by c2s:show() and s2s:show() can be customizied via the]] | |
| 317 print [['columns' argument as described here.]] | |
| 318 print [[]] | |
| 319 print [[Columns can be specified either as "id jid ipv" or as {"id", "jid", "ipv"}.]] | |
| 320 print [[Available columns are:]] | |
| 321 for column, spec in iterators.sorted_pairs(available_columns) do | |
| 322 print("- "..column..": "..(spec.title or capitalize(column))); | |
| 323 -- TODO descriptions | |
| 324 end | |
| 325 print [[]] | |
| 326 print [[Most fields on the internal session structures can also be used as columns]] | |
| 327 -- Also, you can pass a table column specification directly, with mapper callabck and all | |
| 312 end | 328 end |
| 313 end | 329 end |
| 314 | 330 |
| 315 -- Session environment -- | 331 -- Session environment -- |
| 316 -- Anything in def_env will be accessible within the session as a global variable | 332 -- Anything in def_env will be accessible within the session as a global variable |
| 679 elseif session.direction == "incoming" then | 695 elseif session.direction == "incoming" then |
| 680 return session.host or session.to_host, session.from_host; | 696 return session.host or session.to_host, session.from_host; |
| 681 end | 697 end |
| 682 end | 698 end |
| 683 | 699 |
| 684 local available_columns = { | 700 available_columns = { |
| 685 jid = { | 701 jid = { |
| 686 title = "JID"; | 702 title = "JID"; |
| 687 width = 32; | 703 width = 32; |
| 688 key = "full_jid"; | 704 key = "full_jid"; |
| 689 mapper = function(full_jid, session) return full_jid or get_jid(session) end; | 705 mapper = function(full_jid, session) return full_jid or get_jid(session) end; |