Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

parser.has() alway retruning true

Hello,

I´m trying to use CommandLineParser and I have a problem : even if I don´t put anything when I lauch the program (only ./prog ), the function parser.has returns true, as if something was given on the command line.

If someone has an idea of what I am doing wrong, it would be very helpful !

Thanks :)

Here is the code :

const char* keys =
    {
        "{help          |                   | show help message }"
        "{type          |                   | type of the camera}"
        "{camera_number |                   | camera number     }"
    };


int main(int argc, char* argv[])
{

        CommandLineParser parser(argc, argv, keys);

        bool t = parser.has("type");
        cout << " t = " << t << endl;

        bool cm = parser.has("camera_number"); 
        cout << "cm = " << cm << endl; 

        return 0;
}