My bad ... As i'm found of comma alignement, there were spaces in the options values. "file" was "file        " ...

Le samedi 2 février 2013, Olivier Tournaire a écrit :
Thanks Diederick. Did not do the trick.
How I can I access the variables stored in vm ?

Regards,

Olivier

2013/2/2 Diederick C. Niehorster <dcnieho@gmail.com>
This call I use works for me:
po::command_line_parser(argc, ppargv).options(desc).run()

Don't know if there is an important difference here, or if what you
call is just a wrapper around it, but see if that works for you.

Best,
Dee

On Sat, Feb 2, 2013 at 9:14 PM, Olivier Tournaire <olitour@gmail.com> wrote:
> 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<files.size();++i)
>         {
>             path input_path(files[i]);
>             // DO STUFF
>         }
>     }
>     else if (vm.count("directory"))
>
>     {
>         for(unsigned int i=0;i<directories.size();++i)
>         {
>             path input_path(directories[i]);
>             // DO STUFF
>         }
>     }
>     else
>     {
>         cout << "You must choose an option between --hierarchy --file
> --directory!" << endl;
>
>         cout << desc << endl;
>         return 1;
>     }
>
>
>
> Le samedi 2 février 2013, Olivier Tournaire a écrit :
>
>> 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<vector<string> >(&files)
>> , "process the specified files")
>>         ("directory        ", po::value<vector<string> >(&directories)
>> , "process the specified directories");
>>
>>     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<files.size();++i)
>>         {
>>             path input_path(files[i]);
>>             // DO STUFF
>>         }
>>     }
>>     else if (vm.count("directories"))
>>     {
>>         for(unsigned int i=0;i<directories.size();++i)
>>         {
>>             path input_path(directories[i]);
>>             // DO STUFF
>>         }
>>     }
>>     else
>>     {
>>         cout << "You must choose an option between --hierarchy --files
>> --directories!" << endl;
>>         cout << desc << endl;
>>         return 1;
>>     }
>>
>>
>> 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 à