mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 18:53:23 -03:00
rpc: Add option to hide RPCArg
Also, update switch statments to our style guide
This commit is contained in:
parent
fa9708f94c
commit
aaaaad5627
2 changed files with 13 additions and 20 deletions
|
@ -368,9 +368,7 @@ struct Sections {
|
|||
PushSection({indent + "]" + (outer_type != OuterType::NONE ? "," : ""), ""});
|
||||
break;
|
||||
}
|
||||
|
||||
// no default case, so the compiler can warn about missing cases
|
||||
}
|
||||
} // no default case, so the compiler can warn about missing cases
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -489,6 +487,7 @@ std::string RPCHelpMan::ToString() const
|
|||
ret += m_name;
|
||||
bool was_optional{false};
|
||||
for (const auto& arg : m_args) {
|
||||
if (arg.m_hidden) continue;
|
||||
const bool optional = arg.IsOptional();
|
||||
ret += " ";
|
||||
if (optional) {
|
||||
|
@ -510,6 +509,7 @@ std::string RPCHelpMan::ToString() const
|
|||
Sections sections;
|
||||
for (size_t i{0}; i < m_args.size(); ++i) {
|
||||
const auto& arg = m_args.at(i);
|
||||
if (arg.m_hidden) continue;
|
||||
|
||||
if (i == 0) ret += "\nArguments:\n";
|
||||
|
||||
|
@ -589,9 +589,7 @@ std::string RPCArg::ToDescriptionString() const
|
|||
ret += "json array";
|
||||
break;
|
||||
}
|
||||
|
||||
// no default case, so the compiler can warn about missing cases
|
||||
}
|
||||
} // no default case, so the compiler can warn about missing cases
|
||||
}
|
||||
if (m_fallback.which() == 1) {
|
||||
ret += ", optional, default=" + boost::get<std::string>(m_fallback);
|
||||
|
@ -609,9 +607,7 @@ std::string RPCArg::ToDescriptionString() const
|
|||
ret += ", required";
|
||||
break;
|
||||
}
|
||||
|
||||
// no default case, so the compiler can warn about missing cases
|
||||
}
|
||||
} // no default case, so the compiler can warn about missing cases
|
||||
}
|
||||
ret += ")";
|
||||
ret += m_description.empty() ? "" : " " + m_description;
|
||||
|
@ -706,10 +702,7 @@ void RPCResult::ToSections(Sections& sections, const OuterType outer_type, const
|
|||
sections.PushSection({indent + "}" + maybe_separator, ""});
|
||||
return;
|
||||
}
|
||||
|
||||
// no default case, so the compiler can warn about missing cases
|
||||
}
|
||||
|
||||
} // no default case, so the compiler can warn about missing cases
|
||||
CHECK_NONFATAL(false);
|
||||
}
|
||||
|
||||
|
@ -746,9 +739,7 @@ std::string RPCArg::ToStringObj(const bool oneline) const
|
|||
case Type::OBJ_USER_KEYS:
|
||||
// Currently unused, so avoid writing dead code
|
||||
CHECK_NONFATAL(false);
|
||||
|
||||
// no default case, so the compiler can warn about missing cases
|
||||
}
|
||||
} // no default case, so the compiler can warn about missing cases
|
||||
CHECK_NONFATAL(false);
|
||||
}
|
||||
|
||||
|
@ -783,9 +774,7 @@ std::string RPCArg::ToString(const bool oneline) const
|
|||
}
|
||||
return "[" + res + "...]";
|
||||
}
|
||||
|
||||
// no default case, so the compiler can warn about missing cases
|
||||
}
|
||||
} // no default case, so the compiler can warn about missing cases
|
||||
CHECK_NONFATAL(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -144,6 +144,7 @@ struct RPCArg {
|
|||
using Fallback = boost::variant<Optional, /* default value for optional args */ std::string>;
|
||||
const std::string m_names; //!< The name of the arg (can be empty for inner args, can contain multiple aliases separated by | for named request arguments)
|
||||
const Type m_type;
|
||||
const bool m_hidden;
|
||||
const std::vector<RPCArg> m_inner; //!< Only used for arrays or dicts
|
||||
const Fallback m_fallback;
|
||||
const std::string m_description;
|
||||
|
@ -156,9 +157,11 @@ struct RPCArg {
|
|||
const Fallback fallback,
|
||||
const std::string description,
|
||||
const std::string oneline_description = "",
|
||||
const std::vector<std::string> type_str = {})
|
||||
const std::vector<std::string> type_str = {},
|
||||
const bool hidden = false)
|
||||
: m_names{std::move(name)},
|
||||
m_type{std::move(type)},
|
||||
m_hidden{hidden},
|
||||
m_fallback{std::move(fallback)},
|
||||
m_description{std::move(description)},
|
||||
m_oneline_description{std::move(oneline_description)},
|
||||
|
@ -177,6 +180,7 @@ struct RPCArg {
|
|||
const std::vector<std::string> type_str = {})
|
||||
: m_names{std::move(name)},
|
||||
m_type{std::move(type)},
|
||||
m_hidden{false},
|
||||
m_inner{std::move(inner)},
|
||||
m_fallback{std::move(fallback)},
|
||||
m_description{std::move(description)},
|
||||
|
|
Loading…
Add table
Reference in a new issue