Opened 12 years ago

Closed 11 years ago

#5464 closed Support Requests (fixed)

Problem with implicit value in program options

Reported by: lcarreon@… Owned by: Vladimir Prus
Milestone: To Be Determined Component: program_options
Version: Boost 1.45.0 Severity: Problem
Keywords: implicit Cc:

Description

I have created a test program (test_progopts.cpp, please see attachment) to familiarize myself with the program options library. I have compiled and run the test on Windows.

In my test program I have two visible options "help,?" and "bool-opt,a" and one hidden options "input-file". If I run the test program using the following commands, I get my expected result:

test_progopts -? test_progopts --help test_progopts -a test_progopts --bool-opt test_progopts test1.cpp

However, if I run the test program using these commandc, it fails:

test_progopts -a test1.cpp test_progopts --bool-opt test1.cpp

I get the error message:

in option 'bool-opt': invalid bool value

From this error message, it appears that the implicit value is not working. Is my observation valid?

Attachments (1)

test_progopts.cpp (1.6 KB ) - added by lcarreon@… 12 years ago.
Program options library test program

Download all attachments as: .zip

Change History (5)

by lcarreon@…, 12 years ago

Attachment: test_progopts.cpp added

Program options library test program

comment:1 by Leo Carreon <lcarreon@…>, 11 years ago

Hi,

Can I please have some feedback on this.

Regards,

Leo

comment:2 by Vladimir Prus, 11 years ago

Type: BugsSupport Requests

I think the library is behaving at it should. Implicit makes the option accept zero tokens. However, the option will still accept a token if one is provided. Your command line has:

--bool-opt test1.cpp

and test1.cpp is treated as value for --bool-opt. You can use bool_switch function to create optin that never accepts parameters.

Does this answer your question?

comment:3 by Leo Carreon <lcarreon@…>, 11 years ago

Hi,

Thanks for the reply. It does answer my question.

You may close this ticket.

Regards,

Leo

comment:4 by Vladimir Prus, 11 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.