diff --git a/tools/yulPhaser/Phaser.cpp b/tools/yulPhaser/Phaser.cpp index 6a7e7a88f..5f0e3d87b 100644 --- a/tools/yulPhaser/Phaser.cpp +++ b/tools/yulPhaser/Phaser.cpp @@ -142,16 +142,15 @@ CharStream ProgramFactory::loadSource(string const& _sourcePath) return CharStream(sourceCode, _sourcePath); } -int Phaser::main(int _argc, char** _argv) +void Phaser::main(int _argc, char** _argv) { - CommandLineParsingResult parsingResult = parseCommandLine(_argc, _argv); - if (parsingResult.exitCode != 0) - return parsingResult.exitCode; + optional arguments = parseCommandLine(_argc, _argv); + if (!arguments.has_value()) + return; - initialiseRNG(parsingResult.arguments); + initialiseRNG(arguments.value()); - runAlgorithm(parsingResult.arguments); - return 0; + runAlgorithm(arguments.value()); } Phaser::CommandLineDescription Phaser::buildCommandLineDescription() @@ -198,7 +197,7 @@ Phaser::CommandLineDescription Phaser::buildCommandLineDescription() return {keywordDescription, positionalDescription}; } -Phaser::CommandLineParsingResult Phaser::parseCommandLine(int _argc, char** _argv) +optional Phaser::parseCommandLine(int _argc, char** _argv) { auto [keywordDescription, positionalDescription] = buildCommandLineDescription(); @@ -212,13 +211,13 @@ Phaser::CommandLineParsingResult Phaser::parseCommandLine(int _argc, char** _arg if (arguments.count("help") > 0) { cout << keywordDescription << endl; - return {0, move(arguments)}; + return nullopt; } if (arguments.count("input-file") == 0) assertThrow(false, NoInputFiles, "Missing argument: input-file."); - return {0, arguments}; + return arguments; } void Phaser::initialiseRNG(po::variables_map const& _arguments) diff --git a/tools/yulPhaser/Phaser.h b/tools/yulPhaser/Phaser.h index 750255576..9ac6f81f0 100644 --- a/tools/yulPhaser/Phaser.h +++ b/tools/yulPhaser/Phaser.h @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -128,7 +129,7 @@ private: class Phaser { public: - static int main(int argc, char** argv); + static void main(int argc, char** argv); private: struct CommandLineDescription @@ -137,14 +138,8 @@ private: boost::program_options::positional_options_description positionalDescription; }; - struct CommandLineParsingResult - { - int exitCode; - boost::program_options::variables_map arguments; - }; - static CommandLineDescription buildCommandLineDescription(); - static CommandLineParsingResult parseCommandLine(int _argc, char** _argv); + static std::optional parseCommandLine(int _argc, char** _argv); static void initialiseRNG(boost::program_options::variables_map const& _arguments); static void runAlgorithm(boost::program_options::variables_map const& _arguments); diff --git a/tools/yulPhaser/main.cpp b/tools/yulPhaser/main.cpp index a567e355a..d0c00fcda 100644 --- a/tools/yulPhaser/main.cpp +++ b/tools/yulPhaser/main.cpp @@ -26,7 +26,8 @@ int main(int argc, char** argv) { try { - return solidity::phaser::Phaser::main(argc, argv); + solidity::phaser::Phaser::main(argc, argv); + return 0; } catch (boost::program_options::error const& exception) {