aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/util.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2018-12-21 12:29:36 -0500
committerMarcoFalke <falke.marco@gmail.com>2019-01-25 14:16:07 -0500
commitfaa1522e5ec5ec53b2b2b1ed36c11e84939bbb13 (patch)
tree8575b7dbb7409b486e5e38f575bf5ecebc06adb3 /src/rpc/util.cpp
parent5eb32d23841bbcd8eaf7ba49dc4ddfd822bd4773 (diff)
RPCHelpMan: Pass through Result and Examples
Diffstat (limited to 'src/rpc/util.cpp')
-rw-r--r--src/rpc/util.cpp33
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;
}