isoltest: Do not return an error code from --help

This commit is contained in:
Kamil Śliwak 2021-11-15 18:19:37 +01:00
parent 7bace8d25d
commit cf6704ae06
3 changed files with 9 additions and 5 deletions

View File

@ -75,6 +75,9 @@ struct CommonOptions
langutil::EVMVersion evmVersion() const;
virtual void addOptions();
// @returns true if the program should continue, false if it should exit immediately without
// reporting an error.
// Throws ConfigException or std::runtime_error if parsing fails.
virtual bool parse(int argc, char const* const* argv);
// Throws a ConfigException on error
virtual void validate() const;

View File

@ -75,9 +75,9 @@ void IsolTestOptions::addOptions()
bool IsolTestOptions::parse(int _argc, char const* const* _argv)
{
bool const res = CommonOptions::parse(_argc, _argv);
bool const shouldContinue = CommonOptions::parse(_argc, _argv);
if (showHelp || !res)
if (showHelp || !shouldContinue)
{
std::cout << options << std::endl;
return false;
@ -85,7 +85,7 @@ bool IsolTestOptions::parse(int _argc, char const* const* _argv)
enforceGasTest = enforceGasTest || (evmVersion() == langutil::EVMVersion{} && !useABIEncoderV1);
return res;
return shouldContinue;
}
void IsolTestOptions::validate() const

View File

@ -433,8 +433,9 @@ int main(int argc, char const *argv[])
{
auto options = std::make_unique<IsolTestOptions>();
if (!options->parse(argc, argv))
return -1;
bool shouldContinue = options->parse(argc, argv);
if (!shouldContinue)
return 0;
options->validate();
CommonOptions::setSingleton(std::move(options));