mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-15 12:13:24 +00:00
31bc8af862
Add 0001-Fix-missing-option-names.patch: <REASON> Add 0002-Make-lokid-rpc-setting-required-in-SN-mode.patch: <REASON> Add 0003-Make-Default-Required-or-Required-Hidden-compilation.patch: <REASON>
66 lines
2.4 KiB
Diff
66 lines
2.4 KiB
Diff
From: Jason Rhinelander <jason@imaginary.ca>
|
|
Date: Tue, 15 Nov 2022 13:11:11 -0400
|
|
Subject: Fix missing option names
|
|
|
|
At some point between 0.9.9 and 0.9.10 we removed the printing of option
|
|
names when a value doesn't have a default, but this means the config is
|
|
littered with things like:
|
|
|
|
# This option sets the greater foo value.
|
|
|
|
with no actual option name printed out when there is no default.
|
|
|
|
This fixes it by always printing the option name in such a case, just
|
|
with an empty value, e.g.:
|
|
|
|
# This option sets the greater foo value.
|
|
#big-foo=
|
|
---
|
|
llarp/config/definition.cpp | 23 +++++++++++++++--------
|
|
1 file changed, 15 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/llarp/config/definition.cpp b/llarp/config/definition.cpp
|
|
index aa199eb..7617760 100644
|
|
--- a/llarp/config/definition.cpp
|
|
+++ b/llarp/config/definition.cpp
|
|
@@ -152,10 +152,8 @@ namespace llarp
|
|
const std::string& section, std::vector<std::string> comments)
|
|
{
|
|
auto& sectionComments = m_sectionComments[section];
|
|
- for (size_t i = 0; i < comments.size(); ++i)
|
|
- {
|
|
- sectionComments.emplace_back(std::move(comments[i]));
|
|
- }
|
|
+ for (auto& c : comments)
|
|
+ sectionComments.emplace_back(std::move(c));
|
|
}
|
|
|
|
void
|
|
@@ -198,13 +196,22 @@ namespace llarp
|
|
if (useValues and def->getNumberFound() > 0)
|
|
{
|
|
for (const auto& val : def->valuesAsString())
|
|
- fmt::format_to(sect_append, "\n{}={}\n", name, val);
|
|
+ fmt::format_to(sect_append, "\n{}={}", name, val);
|
|
+ *sect_append = '\n';
|
|
}
|
|
- else if (not(def->hidden and not has_comment))
|
|
+ else if (not def->hidden)
|
|
{
|
|
- for (const auto& val : def->defaultValuesAsString())
|
|
- fmt::format_to(sect_append, "\n{}{}={}\n", def->required ? "" : "#", name, val);
|
|
+ if (auto defaults = def->defaultValuesAsString(); not defaults.empty())
|
|
+ for (const auto& val : defaults)
|
|
+ fmt::format_to(sect_append, "\n{}{}={}", def->required ? "" : "#", name, val);
|
|
+ else
|
|
+ // We have no defaults so we append it as "#opt-name=" so that we show the option name,
|
|
+ // and make it simple to uncomment and edit to the desired value.
|
|
+ fmt::format_to(sect_append, "\n#{}=", name);
|
|
+ *sect_append = '\n';
|
|
}
|
|
+ else if (has_comment)
|
|
+ *sect_append = '\n';
|
|
});
|
|
|
|
if (sect_str.empty())
|