diff options
Diffstat (limited to 'src/rpc/util.cpp')
-rw-r--r-- | src/rpc/util.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index b91baee4ac..4275cc09a8 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -242,8 +242,12 @@ struct Sections { } }; -RPCHelpMan::RPCHelpMan(const std::string& name, const std::string& description, const std::vector<RPCArg>& args) - : m_name{name}, m_description{description}, m_args{args} +RPCHelpMan::RPCHelpMan(std::string name, std::string description, std::vector<RPCArg> args, RPCResults results, RPCExamples examples) + : m_name{std::move(name)}, + m_description{std::move(description)}, + m_args{std::move(args)}, + m_results{std::move(results)}, + m_examples{std::move(examples)} { std::set<std::string> named_args; for (const auto& arg : m_args) { @@ -252,6 +256,25 @@ RPCHelpMan::RPCHelpMan(const std::string& name, const std::string& description, } } +std::string RPCResults::ToDescriptionString() const +{ + std::string result; + for (const auto& r : m_results) { + if (r.m_cond.empty()) { + result += "\nResult:\n"; + } else { + result += "\nResult (" + r.m_cond + "):\n"; + } + result += r.m_result; + } + return result; +} + +std::string RPCExamples::ToDescriptionString() const +{ + return m_examples.empty() ? m_examples : "\nExamples:\n" + m_examples; +} + std::string RPCHelpMan::ToString() const { std::string ret; @@ -292,6 +315,12 @@ std::string RPCHelpMan::ToString() const } ret += sections.ToString(); + // Result + ret += m_results.ToDescriptionString(); + + // Examples + ret += m_examples.ToDescriptionString(); + return ret; } |