summaryrefslogtreecommitdiff
path: root/modules/commands/cs_flags.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2011-12-19 15:37:15 -0500
committerAdam <Adam@anope.org>2011-12-19 15:37:15 -0500
commit45fc3ce1c41b06af6e03712988870ead95b72435 (patch)
tree7b574d077f77707edb3916fb43dfa30dec8b0f54 /modules/commands/cs_flags.cpp
parentd320c73f23ff7a9b848b86b59c6bf91c1254e410 (diff)
Fixed formatting of many lists and INFO outputs
Diffstat (limited to 'modules/commands/cs_flags.cpp')
-rw-r--r--modules/commands/cs_flags.cpp69
1 files changed, 42 insertions, 27 deletions
diff --git a/modules/commands/cs_flags.cpp b/modules/commands/cs_flags.cpp
index 3003855e7..a720a2a79 100644
--- a/modules/commands/cs_flags.cpp
+++ b/modules/commands/cs_flags.cpp
@@ -221,45 +221,60 @@ class CommandCSFlags : public Command
const Anope::string &arg = params.size() > 2 ? params[2] : "";
if (!ci->GetAccessCount())
+ {
source.Reply(_("%s access list is empty."), ci->name.c_str());
- else
+ return;
+ }
+
+ ListFormatter list;
+
+ list.addColumn("Number").addColumn("Mask").addColumn("Flags").addColumn("Creator").addColumn("Created");
+
+ unsigned count = 0;
+ for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i)
{
- unsigned total = 0;
+ ChanAccess *access = ci->GetAccess(i);
+ const Anope::string &flags = FlagsChanAccess::DetermineFlags(access);
- for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i)
+ if (!arg.empty())
{
- ChanAccess *access = ci->GetAccess(i);
- const Anope::string &flags = FlagsChanAccess::DetermineFlags(access);
-
- if (!arg.empty())
+ if (arg[0] == '+')
{
- if (arg[0] == '+')
- {
- bool pass = true;
- for (size_t j = 1; j < arg.length(); ++j)
- if (flags.find(arg[j]) == Anope::string::npos)
- pass = false;
- if (pass == false)
- continue;
- }
- else if (!Anope::Match(access->mask, arg))
+ bool pass = true;
+ for (size_t j = 1; j < arg.length(); ++j)
+ if (flags.find(arg[j]) == Anope::string::npos)
+ pass = false;
+ if (pass == false)
continue;
}
+ else if (!Anope::Match(access->mask, arg))
+ continue;
+ }
- if (++total == 1)
- {
- source.Reply(_("Flags list for %s"), ci->name.c_str());
- }
+ ListFormatter::ListEntry entry;
+ ++count;
+ entry["Number"] = stringify(i + 1);
+ entry["Mask"] = access->mask;
+ entry["Flags"] = FlagsChanAccess::DetermineFlags(access);
+ entry["Creator"] = access->creator;
+ entry["Created"] = do_strftime(access->created, source.u->Account(), true);
+ list.addEntry(entry);
+ }
- source.Reply(_(" %3d %-10s +%-10s [last modified on %s by %s]"), i + 1, access->mask.c_str(), FlagsChanAccess::DetermineFlags(access).c_str(), do_strftime(access->created, source.u->Account(), true).c_str(), access->creator.c_str());
- }
+ if (list.isEmpty())
+ source.Reply(_("No matching entries on %s access list."), ci->name.c_str());
+ else
+ {
+ std::vector<Anope::string> replies;
+ list.Process(replies);
- if (total == 0)
- source.Reply(_("No matching entries on %s access list."), ci->name.c_str());
- else if (total == ci->GetAccessCount())
+ source.Reply(_("Flags list for %s"), ci->name.c_str());
+ for (unsigned i = 0; i < replies.size(); ++i)
+ source.Reply(replies[i]);
+ if (count == ci->GetAccessCount())
source.Reply(_("End of access list."));
else
- source.Reply(_("End of access list - %d/%d entries shown."), total, ci->GetAccessCount());
+ source.Reply(_("End of access list - %d/%d entries shown."), count, ci->GetAccessCount());
}
}