1
0
mirror of https://github.com/anope/anope.git synced 2026-07-09 10:03:14 +02:00

Sort options in the information formatter output.

This commit is contained in:
Sadie Powell
2025-09-29 13:00:17 +01:00
parent 1275fd01a7
commit 4dada51e08
3 changed files with 21 additions and 19 deletions
+2 -1
View File
@@ -114,7 +114,8 @@ class CoreExport InfoFormatter final
private:
size_t longest = 0;
NickCore *nc;
std::vector<std::pair<Anope::string, Anope::string> > replies;
std::vector<Anope::string> options;
std::vector<std::pair<Anope::string, Anope::string>> replies;
public:
InfoFormatter(NickCore *nc);
+5 -2
View File
@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Anope\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-23 18:18+0100\n"
"PO-Revision-Date: 2025-09-23 18:18+0100\n"
"POT-Creation-Date: 2025-09-29 12:59+0100\n"
"PO-Revision-Date: 2025-09-29 13:00+0100\n"
"Last-Translator: Sadie Powell <sadie@witchery.services>\n"
"Language-Team: English\n"
"Language: en_US\n"
@@ -5899,6 +5899,9 @@ msgstr ""
msgid "Validates a previously requested vhost using DNS"
msgstr ""
msgid "Validates a previously requested vhost using DNS. If you own the domain you have requested as a vhost you can validate your ownership of it using a DNS TXT record to approve your own vhost."
msgstr ""
msgid "Value"
msgstr ""
+14 -16
View File
@@ -264,6 +264,19 @@ void InfoFormatter::SendTo(CommandSource &source)
const auto flexible = sourcenc ? sourcenc->HasExt("NS_FLEXIBLE") : false;
const auto *monospace = !flexible && sourcenc && sourcenc->HasExt("NS_MONOSPACE") ? "\021" : "";
if (!this->options.empty())
{
std::sort(this->options.begin(), this->options.end());
auto &optstr = (*this)[_("Options")];
for (const auto& option : this->options)
{
if (!optstr.empty())
optstr += ", ";
optstr += option;
}
}
for (const auto &[key, value] : this->replies)
{
if (flexible)
@@ -291,22 +304,7 @@ Anope::string &InfoFormatter::operator[](const Anope::string &key)
void InfoFormatter::AddOption(const Anope::string &opt)
{
Anope::string options = Language::Translate(this->nc, "Options");
Anope::string *optstr = NULL;
for (auto &[option, value] : this->replies)
{
if (option == options)
{
optstr = &value;
break;
}
}
if (!optstr)
optstr = &(*this)[_("Options")];
if (!optstr->empty())
*optstr += ", ";
*optstr += Language::Translate(nc, opt.c_str());
this->options.push_back(Language::Translate(nc, opt.c_str()));
}