-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reverting change for implicit_option that happened in boost 1.59 #25
Comments
Thanks for your comment. I've posted on the mailing list to seek more opinions, and will restore the previous behavior unless I hear strong arguments against it. |
Summary: Our internal version of boost contains a patch that reverts the following commit to boost filesystem module: boostorg/program_options@88dea3c It was done due to a breaking change that disallows the use of "--key value" for implicit options, allowing only "--key=value" style syntax. Since there are too many tests to fix, and it's probably going to be reverted in the upstream as well (see below), removing the `override` keyword here to fix folly build. boostorg/program_options#25 Reviewed By: meyering Differential Revision: D4415347 fbshipit-source-id: c215331338b3aa218d26890a83aa0b363514fe79
Anything to be done about this? My user simply won't use
or
or
And this also breaks from many common command line behaviors many people are familiar with including positional file input paths |
This is also a pain point for me. I have many scripts scattered throughout several codebases that use the old "permissive" syntax, and they are broken in newer versions of Boost... |
Is there anyway to build boost dev while setting the program_options Maybe fork and provide a way for users now stuck at 1.57 because of this module? |
A workaround from http://lists.boost.org/Archives/boost/2017/01/232272.php template <typename T>
struct greedy_implicit_value : public po::typed_value<T>
{
using base = po::typed_value<T>;
greedy_implicit_value(const T& value) : base(nullptr)
{
base::implicit_value(value);
}
bool adjacent_tokens_only() const override { return false; }
unsigned max_tokens() const override { return 1; }
};
template <typename T>
po::typed_value* implicit_value(const T& value)
{
return new greedy_implicit_value<T>(value);
} |
Maybe I don't know where to put that; I tried that back then but nothing happened Where does it go? |
I did manage to build boost dev 1.64 for everything while setting the program_options to tags/boost-1.57.0
Initial tests look good |
This is how I adapted it to my code; it works for me: #if (BOOST_VERSION >= 105900)
template <typename T> struct greedy_implicit_value_impl : public po::typed_value<T> {
using base = po::typed_value<T>;
greedy_implicit_value_impl() : base(nullptr) {}
bool adjacent_tokens_only() const override { return false; }
unsigned max_tokens() const override { return 1; }
};
template <typename T> po::typed_value<T>* greedy_implicit_value() {
return new greedy_implicit_value_impl<T>();
}
#else
# define greedy_implicit_value po::value
#endif
po::options_description makeOptions() {
po::options_description opts("options name");
opts.add_options()
("option_name",
greedy_implicit_value<double>()->implicit_value(0.0)->value_name("opt"),
"option description")
return opts;
}
|
I've pushed a series of commits to go back to original behavior, the last one being b35e654 |
I am trying to convert a bool_switch option to an implicit_value one so I can change the default behavior so that the switch is on. If users want to turn it off in the future, I want them to use --option=false. This seems better than adding another parameter like "--no-option" and letting the "--option" become a vestigial no-op. But of course I don't want to break anybody's scripts that already use it like
The other overload you removed the "but if given" part. Unfortunately it doesn't seem trivial to return to the behavior I need. Am I missing something, or how hard would it be to make it a |
Dear Vladimir Prus. This is a follow up to your comment in (http://stackoverflow.com/questions/31921200/how-to-have-an-optional-option-value-in-boost-program-options)
implicit_option changed its behaviour in boost 1.59 so that --option_name option_value no longer works and needs to be written as --option_name=option_value. I would find it useful if the original behavior was restored and both formats worked (and the documentation changed to reflect this). Thank you.
The text was updated successfully, but these errors were encountered: