genetic-images/src/parseargs.cc

27 lines
1.1 KiB
C++
Raw Normal View History

2019-03-19 12:49:37 +00:00
#include "parseargs.hh"
#include <boost/program_options.hpp>
#include <cstdlib>
#include <iostream>
#include <string>
std::tuple<std::string, std::string, bool> 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");
po::variables_map vm;
po::store(po::parse_command_line(t_ac, t_av, desc), vm);
po::notify(vm);
if (vm.count("help") || !vm.count("input")) {
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);
}