Opened 12 years ago
Closed 11 years ago
#5464 closed Support Requests (fixed)
Problem with implicit value in program options
Reported by: | 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)
Change History (5)
by , 12 years ago
Attachment: | test_progopts.cpp added |
---|
comment:2 by , 11 years ago
Type: | Bugs → Support 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 , 11 years ago
Hi,
Thanks for the reply. It does answer my question.
You may close this ticket.
Regards,
Leo
comment:4 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Program options library test program