aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/util.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2018-12-05 11:43:55 -0500
committerMarcoFalke <falke.marco@gmail.com>2018-12-10 14:08:20 -0500
commitfa9a5bc1a0748afdc226f00abfd4f9e5df6d9139 (patch)
tree9e3a5bca67f3b2c278c071fa1c202feda6d4e04c /src/rpc/util.cpp
parent5f23460c7e316fe7c944680f3feff07ebb867f70 (diff)
downloadbitcoin-fa9a5bc1a0748afdc226f00abfd4f9e5df6d9139.tar.xz
RPCHelpMan: Support required arguments after optional ones
Diffstat (limited to 'src/rpc/util.cpp')
-rw-r--r--src/rpc/util.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp
index 740f8351fe..b91baee4ac 100644
--- a/src/rpc/util.cpp
+++ b/src/rpc/util.cpp
@@ -258,20 +258,19 @@ std::string RPCHelpMan::ToString() const
// Oneline summary
ret += m_name;
- bool is_optional{false};
+ bool was_optional{false};
for (const auto& arg : m_args) {
ret += " ";
if (arg.m_optional) {
- if (!is_optional) ret += "( ";
- is_optional = true;
+ if (!was_optional) ret += "( ";
+ was_optional = true;
} else {
- // Currently we still support unnamed arguments, so any argument following an optional argument must also be optional
- // If support for positional arguments is deprecated in the future, remove this line
- assert(!is_optional);
+ if (was_optional) ret += ") ";
+ was_optional = false;
}
ret += arg.ToString(/* oneline */ true);
}
- if (is_optional) ret += " )";
+ if (was_optional) ret += " )";
ret += "\n";
// Description
@@ -285,8 +284,7 @@ std::string RPCHelpMan::ToString() const
if (i == 0) ret += "\nArguments:\n";
// Push named argument name and description
- const auto str_wrapper = (arg.m_type == RPCArg::Type::STR || arg.m_type == RPCArg::Type::STR_HEX) ? "\"" : "";
- sections.m_sections.emplace_back(std::to_string(i + 1) + ". " + str_wrapper + arg.m_name + str_wrapper, arg.ToDescriptionString());
+ sections.m_sections.emplace_back(std::to_string(i + 1) + ". " + arg.m_name, arg.ToDescriptionString());
sections.m_max_pad = std::max(sections.m_max_pad, sections.m_sections.back().m_left.size());
// Recursively push nested args