equal
deleted
inserted
replaced
80 section = "cron"; |
80 section = "cron"; |
81 section_desc = "View and manage recurring tasks"; |
81 section_desc = "View and manage recurring tasks"; |
82 name = "tasks"; |
82 name = "tasks"; |
83 desc = "View registered tasks"; |
83 desc = "View registered tasks"; |
84 args = {}; |
84 args = {}; |
85 handler = function (self, host) |
85 handler = function (self, filter_host) |
86 local format_table = require "prosody.util.human.io".table; |
86 local format_table = require "prosody.util.human.io".table; |
87 local it = require "util.iterators"; |
87 local it = require "util.iterators"; |
88 local row = format_table({ |
88 local row = format_table({ |
89 { title = "Host", width = "2p" }; |
89 { title = "Host", width = "2p" }; |
90 { title = "Task", width = "3p" }; |
90 { title = "Task", width = "3p" }; |
92 { title = "When", width = "1p" }; |
92 { title = "When", width = "1p" }; |
93 { title = "Last run", width = "20" }; |
93 { title = "Last run", width = "20" }; |
94 }, self.session.width); |
94 }, self.session.width); |
95 local print = self.session.print; |
95 local print = self.session.print; |
96 print(row()); |
96 print(row()); |
97 for host in it.sorted_pairs(host and { [host]=true } or active_hosts) do |
97 for host in it.sorted_pairs(filter_host and { [filter_host]=true } or active_hosts) do |
98 for _, task in ipairs(module:context(host):get_host_items("task")) do |
98 for _, task in ipairs(module:context(host):get_host_items("task")) do |
99 print(row { host, task.id, task.name, task.when, task.last and os.date("%Y-%m-%d %R:%S", task.last) or "never" }); |
99 print(row { host, task.id, task.name, task.when, task.last and os.date("%Y-%m-%d %R:%S", task.last) or "never" }); |
100 --self.session.print(require "util.serialization".serialize(task, "debug")); |
100 --self.session.print(require "util.serialization".serialize(task, "debug")); |
101 --print(""); |
101 --print(""); |
102 end |
102 end |