commit e57babef7128239e2c8ff952f4e33a3671bd6a42
parent 9418ba5eed14ddd7f544b9850bae55f665e5bc0c
Author: Juan F. Meleiro <juan@juanmeleiro.mat.br>
Date: Wed, 31 May 2023 11:59:50 -0300
monthly: Refactor formating of entries
Diffstat:
1 file changed, 24 insertions(+), 22 deletions(-)
diff --git a/monthly/format.lua b/monthly/format.lua
@@ -13,34 +13,36 @@ f:close()
-- x deregistration
-- observations
-reasons = {
- a = "Abandoned",
- l = "Lawless",
- v = "Voluntary",
- d = "Deported",
- w = "Writ of FAGE",
- p = "Proposal",
- r = "Ratification",
- u = "Uknown",
- s = "Still registered",
- b = "Banned",
- k = "Deregistered emself by mista(k)e",
- e = "Destroyed",
- x = "Exiled"
-}
-
EVENT_FORMAT = " %s %s => %s\n"
CONTACT_FORMAT = " aka %s <%s>\n"
+function format(s, d)
+ res = s
+ for k in string.gmatch(s, "{([^{}|]+)}") do
+ if d[k] then
+ res = string.gsub(res, "{"..k.."}", d[k])
+ else
+ res = string.gsub(res, "{"..k.."}", "??")
+ end
+ end
+ return res
+end
+
for n,h in pairs(players) do
io.write("===============\n"..n.."\n")
for _,e in ipairs(h) do
- io.write(string.format(" %s <%s> (%s--%s; %s)\n",
- e.name,
- e.contact,
- e.registration,
- e.deregistration or "now",
- reasons[e.reason]))
+ if e.reason == "s" then
+ f = " ({reason}) {name} <{contact}> ({registration}--now)\n"
+ else
+ f = " ({reason}) {name} <{contact}> ({registration}--{deregistration})\n"
+ end
+ io.write(format(f, e))
+ -- io.write(string.format(" (%s) %s <%s> (%s--%s)\n",
+ -- e.reason,
+ -- e.name,
+ -- e.contact,
+ -- e.registration,
+ -- e.deregistration or "now"))
end
io.write("\n")
end