Oups. Made à mistake ... However the issue is still there:
if (vm.count("hierarchy"))
{
path input_path(hierarchy);
// DO STUFF
}
else if (vm.count("file"))
{
for(unsigned int i=0;i Hi all, I am having troubles with program options. I try to test if at least some
of the available options are passed on the command line, but fail for some
reason using count("option_name"). Here is my code: int main(int argc, char** argv)
{
string hierarchy;
vector<string> files, directories;
double vertical_shift;
bool show_progress, single_file, single_dir;
int target_EPSG, nb_threads; po::options_description desc("Allowed options");
desc.add_options()
("help
,h"
, "Produce help message")
("hierarchy ",
po::value<string>(&hierarchy)
, "process a hierarchy)
("file ", po::value (&files) , "process the
specified files")
("directory ", po::value po::variables_map vm;
try
{
po::store(po::parse_command_line(argc, argv, desc), vm); if (vm.count("help"))
{
cout << desc << "\n";
return 1;
} po::notify(vm);
}
catch (const po::error &e)
{
cerr << "Exception caught ! --> " << e.what() << endl;
cout << desc << endl;
return 1;
} if (vm.count("hierarchy"))
{
path input_path(hierarchy);
// DO STUFF
}
else if (vm.count("files"))
{
for(unsigned int i=0;i I always fall in the "else". What am I doing wrong? For instance with this command line : ./acute_coordinates_transform
--hierarchy ~/work/data/ À other question: is there à way to specify that 1 of the 3 options is
required (and only 1)? Hope you cloud help. Regards, Olivier