Skip to content

Commit aaaaad5

Browse files
author
MarcoFalke
committed
rpc: Add option to hide RPCArg
Also, update switch statments to our style guide
1 parent fa9708f commit aaaaad5

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

src/rpc/util.cpp

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,7 @@ struct Sections {
368368
PushSection({indent + "]" + (outer_type != OuterType::NONE ? "," : ""), ""});
369369
break;
370370
}
371-
372-
// no default case, so the compiler can warn about missing cases
373-
}
371+
} // no default case, so the compiler can warn about missing cases
374372
}
375373

376374
/**
@@ -489,6 +487,7 @@ std::string RPCHelpMan::ToString() const
489487
ret += m_name;
490488
bool was_optional{false};
491489
for (const auto& arg : m_args) {
490+
if (arg.m_hidden) continue;
492491
const bool optional = arg.IsOptional();
493492
ret += " ";
494493
if (optional) {
@@ -510,6 +509,7 @@ std::string RPCHelpMan::ToString() const
510509
Sections sections;
511510
for (size_t i{0}; i < m_args.size(); ++i) {
512511
const auto& arg = m_args.at(i);
512+
if (arg.m_hidden) continue;
513513

514514
if (i == 0) ret += "\nArguments:\n";
515515

@@ -589,9 +589,7 @@ std::string RPCArg::ToDescriptionString() const
589589
ret += "json array";
590590
break;
591591
}
592-
593-
// no default case, so the compiler can warn about missing cases
594-
}
592+
} // no default case, so the compiler can warn about missing cases
595593
}
596594
if (m_fallback.which() == 1) {
597595
ret += ", optional, default=" + boost::get<std::string>(m_fallback);
@@ -609,9 +607,7 @@ std::string RPCArg::ToDescriptionString() const
609607
ret += ", required";
610608
break;
611609
}
612-
613-
// no default case, so the compiler can warn about missing cases
614-
}
610+
} // no default case, so the compiler can warn about missing cases
615611
}
616612
ret += ")";
617613
ret += m_description.empty() ? "" : " " + m_description;
@@ -706,10 +702,7 @@ void RPCResult::ToSections(Sections& sections, const OuterType outer_type, const
706702
sections.PushSection({indent + "}" + maybe_separator, ""});
707703
return;
708704
}
709-
710-
// no default case, so the compiler can warn about missing cases
711-
}
712-
705+
} // no default case, so the compiler can warn about missing cases
713706
CHECK_NONFATAL(false);
714707
}
715708

@@ -746,9 +739,7 @@ std::string RPCArg::ToStringObj(const bool oneline) const
746739
case Type::OBJ_USER_KEYS:
747740
// Currently unused, so avoid writing dead code
748741
CHECK_NONFATAL(false);
749-
750-
// no default case, so the compiler can warn about missing cases
751-
}
742+
} // no default case, so the compiler can warn about missing cases
752743
CHECK_NONFATAL(false);
753744
}
754745

@@ -783,9 +774,7 @@ std::string RPCArg::ToString(const bool oneline) const
783774
}
784775
return "[" + res + "...]";
785776
}
786-
787-
// no default case, so the compiler can warn about missing cases
788-
}
777+
} // no default case, so the compiler can warn about missing cases
789778
CHECK_NONFATAL(false);
790779
}
791780

src/rpc/util.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ struct RPCArg {
144144
using Fallback = boost::variant<Optional, /* default value for optional args */ std::string>;
145145
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)
146146
const Type m_type;
147+
const bool m_hidden;
147148
const std::vector<RPCArg> m_inner; //!< Only used for arrays or dicts
148149
const Fallback m_fallback;
149150
const std::string m_description;
@@ -156,9 +157,11 @@ struct RPCArg {
156157
const Fallback fallback,
157158
const std::string description,
158159
const std::string oneline_description = "",
159-
const std::vector<std::string> type_str = {})
160+
const std::vector<std::string> type_str = {},
161+
const bool hidden = false)
160162
: m_names{std::move(name)},
161163
m_type{std::move(type)},
164+
m_hidden{hidden},
162165
m_fallback{std::move(fallback)},
163166
m_description{std::move(description)},
164167
m_oneline_description{std::move(oneline_description)},
@@ -177,6 +180,7 @@ struct RPCArg {
177180
const std::vector<std::string> type_str = {})
178181
: m_names{std::move(name)},
179182
m_type{std::move(type)},
183+
m_hidden{false},
180184
m_inner{std::move(inner)},
181185
m_fallback{std::move(fallback)},
182186
m_description{std::move(description)},

0 commit comments

Comments
 (0)