Moved program_options add_options to a helper function to allow defaults to be set by derived class constructor before immutable options are created by parent

This commit is contained in:
Sean Hawkes 2021-09-18 04:55:50 -05:00
parent 20ca5c1361
commit f47e918caa
4 changed files with 14 additions and 3 deletions

View File

@ -91,6 +91,11 @@ CommonOptions::CommonOptions(std::string _caption):
po::options_description::m_default_line_length, po::options_description::m_default_line_length,
po::options_description::m_default_line_length - 23 po::options_description::m_default_line_length - 23
) )
{
}
void CommonOptions::addOptions()
{ {
options.add_options() options.add_options()
("evm-version", po::value(&evmVersionString), "which evm version to use") ("evm-version", po::value(&evmVersionString), "which evm version to use")

View File

@ -70,6 +70,7 @@ struct CommonOptions
langutil::EVMVersion evmVersion() const; langutil::EVMVersion evmVersion() const;
virtual addOptions();
virtual bool parse(int argc, char const* const* argv); virtual bool parse(int argc, char const* const* argv);
// Throws a ConfigException on error // Throws a ConfigException on error
virtual void validate() const; virtual void validate() const;

View File

@ -58,6 +58,13 @@ std::string editorPath()
IsolTestOptions::IsolTestOptions(std::string* _editor): IsolTestOptions::IsolTestOptions(std::string* _editor):
CommonOptions(description) CommonOptions(description)
{
enforceViaYul = true;
enforceGasTest = (evmVersion() == langutil::EVMVersion{});
enforceGasTestMinValue = 100000;
}
void IsolTestOptions::addOptions()
{ {
options.add_options() options.add_options()
("editor", po::value<std::string>(_editor)->default_value(editorPath()), "Path to editor for opening test files.") ("editor", po::value<std::string>(_editor)->default_value(editorPath()), "Path to editor for opening test files.")
@ -76,9 +83,6 @@ bool IsolTestOptions::parse(int _argc, char const* const* _argv)
std::cout << options << std::endl; std::cout << options << std::endl;
return false; return false;
} }
enforceViaYul = true;
enforceGasTest = (evmVersion() == langutil::EVMVersion{});
enforceGasTestMinValue = 100000;
return res; return res;
} }

View File

@ -35,6 +35,7 @@ struct IsolTestOptions: CommonOptions
std::string testFilter = std::string{}; std::string testFilter = std::string{};
IsolTestOptions(std::string* _editor); IsolTestOptions(std::string* _editor);
void addOptions() override;
bool parse(int _argc, char const* const* _argv) override; bool parse(int _argc, char const* const* _argv) override;
void validate() const override; void validate() const override;
}; };