From 94095605979e44ec20539e3e925875591fe027a4 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 25 Feb 2026 15:38:05 +0000 Subject: [PATCH] Tweak the layout and ergonomics the ExampleWrapper class. --- include/textproc.h | 2 +- src/misc.cpp | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/textproc.h b/include/textproc.h index 964eb6b2f..12f28be01 100644 --- a/include/textproc.h +++ b/include/textproc.h @@ -113,7 +113,7 @@ private: std::vector entries; public: - void AddEntry(const Anope::string &example, const Anope::string &desc, const Anope::string &priv = ""); + ExampleWrapper &AddEntry(const Anope::string &example, const Anope::string &desc, const Anope::string &priv = ""); void SendTo(CommandSource &source); }; diff --git a/src/misc.cpp b/src/misc.cpp index 06ea343de..44d4cdc91 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -310,12 +310,13 @@ void InfoFormatter::AddOption(const Anope::string &opt) this->options.push_back(Language::Translate(nc, opt.c_str())); } -void ExampleWrapper::AddEntry(const Anope::string &example, const Anope::string &desc, const Anope::string &priv) +ExampleWrapper &ExampleWrapper::AddEntry(const Anope::string &example, const Anope::string &desc, const Anope::string &priv) { auto &entry = entries.emplace_back(); entry.example = example; entry.description = desc; entry.privilege = priv; + return *this; } void ExampleWrapper::SendTo(CommandSource &source) @@ -339,15 +340,17 @@ void ExampleWrapper::SendTo(CommandSource &source) header = false; } - source.Reply(" "); if (flexible) { - source.Reply("\002%s %s\002: %s", source.command.c_str(), + source.Reply("\002%s%s%s\002: %s", source.command.c_str(), entry.example.empty() ? "" : " ", entry.example.c_str(), entry.description.c_str()); } else { - const auto full_example = Anope::Format("%s %s", source.command.c_str(), entry.example.c_str()); + source.Reply(" "); + const auto full_example = Anope::Format("%s%s%s", source.command.c_str(), + entry.example.empty() ? "" : " ", entry.example.c_str()); + LineWrapper elw(Language::Translate(source.nc, full_example.c_str()), max_length - 2); for (Anope::string line; elw.GetLine(line); ) source.Reply("%s \002%s\002", monospace, line.c_str());