Skip to content

Commit

Permalink
Add GetSectionArg() Helper
Browse files Browse the repository at this point in the history
Add helper function to read signet_chain args from config
  • Loading branch information
BrandonOdiwuor committed Jun 7, 2024
1 parent 50f4ca2 commit 8d8a728
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/common/args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,21 @@ std::optional<const ArgsManager::Command> ArgsManager::GetCommand() const
return ret;
}

std::vector<common::SettingsValue> ArgsManager::GetSectionArg(const std::string& section, const std::string& strArg) const
{
std::vector<common::SettingsValue> result;
LOCK(cs_args);
if (auto* _section = common::FindKey(m_settings.ro_config, section)) {
if (auto* values = common::FindKey(*_section, strArg)) {
for (int i = 0; i < values->size(); i++) {
result.push_back((*values)[i]);
}

}
}
return result;
}

std::vector<std::string> ArgsManager::GetArgs(const std::string& strArg) const
{
std::vector<std::string> result;
Expand Down
9 changes: 9 additions & 0 deletions src/common/args.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,15 @@ class ArgsManager
*/
void ClearPathCache();

/**
* Retrieves values associated with a specified argument in a given configuration section.
*
* @param section section in m_settings.ro_config to seach
* @param strArg Argument to get (e.g. "-foo")
* @return Vector of string values for the argument in the configuration file.
*/
std::vector<common::SettingsValue> GetSectionArg(const std::string& section, const std::string& strArg) const;

/**
* Return a vector of strings of the given argument
*
Expand Down

0 comments on commit 8d8a728

Please sign in to comment.