Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Making sure --hpx:help does not throw for required (but missing) argu…
…ments
- Loading branch information
Showing
4 changed files
with
74 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
tests/regressions/util/command_line_required_arguments_2990.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) 2017 Igor Krivenko | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#include <hpx/hpx_init.hpp> | ||
#include <hpx/hpx.hpp> | ||
|
||
#include <iostream> | ||
#include <string> | ||
#include <vector> | ||
|
||
using namespace boost::program_options; | ||
|
||
int hpx_main(variables_map& vm) | ||
{ | ||
std::cout << "Value of reqopt1: " << vm["reqopt1"].as<int>() << std::endl; | ||
std::cout << "Value of reqopt2: " << vm["reqopt2"].as<double>() | ||
<< std::endl; | ||
std::cout << "Value of reqopt3: " << vm["reqopt3"].as<std::string>() | ||
<< std::endl; | ||
|
||
return hpx::finalize(); | ||
} | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
std::vector<std::string> cfg = { | ||
"hpx.commandline.rethrow_errors!=1" | ||
}; | ||
|
||
char help_option[] = "--hpx:help"; | ||
|
||
std::vector<char*> newargv; | ||
for (int i = 0; i != argc; ++i) | ||
{ | ||
newargv.push_back(argv[i]); | ||
} | ||
newargv.push_back(help_option); | ||
newargv.push_back(nullptr); | ||
|
||
options_description op("Issue #2990\n\nUsage: issue2990 [options]"); | ||
|
||
op.add_options() | ||
("reqopt1", value<int>()->required(), "Required option 1") | ||
("reqopt2", value<double>()->required(), "Required option 2") | ||
("reqopt3", value<std::string>()->required(), "Required option 3"); | ||
|
||
return hpx::init(op, argc + 1, newargv.data(), cfg); | ||
} |