added number of iterations to arguments list

This commit is contained in:
Phuntsok Drak-pa 2019-03-19 14:22:44 +01:00
parent 3654e56d2e
commit 069b739174
2 changed files with 15 additions and 8 deletions

View File

@ -4,13 +4,18 @@
#include <iostream>
#include <string>
std::tuple<std::string, std::string, bool> parse_args(int t_ac, char **t_av) {
constexpr int DEFAULT_ITERATIONS = 5000;
std::tuple<std::string, std::string, bool, int> parse_args(int t_ac,
char **t_av) {
namespace po = boost::program_options;
po::options_description desc("Allowed options");
desc.add_options()("help,h", "Display this help message")(
"input,i", po::value<std::string>(), "Input image")(
"output,o", po::value<std::string>(),
"Image or video output path")("video,v", "Enable video output");
"Image or video output path (default: input path + \"_output\")")(
"iterations,n", po::value<int>(),
"Number of iterations (default: 5000)")("video,v", "Enable video output");
po::variables_map vm;
po::store(po::parse_command_line(t_ac, t_av, desc), vm);
po::notify(vm);
@ -18,9 +23,11 @@ std::tuple<std::string, std::string, bool> parse_args(int t_ac, char **t_av) {
std::cout << desc << "\n";
std::exit(1);
}
return std::make_tuple(vm["input"].as<std::string>(),
(vm.count("output")) ? vm["output"].as<std::string>()
: vm["input"].as<std::string>() +
std::string{"_output"},
(vm.count("video")) ? true : false);
return std::make_tuple(
vm["input"].as<std::string>(),
vm.count("output")
? vm["output"].as<std::string>()
: vm["input"].as<std::string>() + std::string{"_output"},
vm.count("video") ? true : false,
vm.count("iterations") ? vm["iterations"].as<int>() : DEFAULT_ITERATIONS);
}

View File

@ -4,6 +4,6 @@
#include <string>
#include <tuple>
std::tuple<std::string, std::string, bool> parse_args(int, char**);
std::tuple<std::string, std::string, bool, int> parse_args(int, char **);
#endif /* GENETIC_IMAGE_INCLUDE_GENIMG_PARSEARGS_HH_ */