-
Notifications
You must be signed in to change notification settings - Fork 273
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
[RFC] Refactor command line options #4404
base: develop
Are you sure you want to change the base?
[RFC] Refactor command line options #4404
Conversation
Looks decent, though I had something like this in mind: https://www.npmjs.com/package/commander where each command could have its own parser. But it requires |
I don't think that we have an issue with the raw parsing. Most of the mess comes from duplicating the translation into a configuration object (optionst) across all driver programs. My vague plans for the second step there are to associate these translations with a cmdline_definitiont/cmdline_optiont. That will factor out all the verbose cmdline->options code. In third step we could then transition to more structured configuration objects. |
A structured way of defining command line options.
6ecae31
to
a1496e0
Compare
These sound like reasonable goals. Bringing some sanity to the option handling of I'm not sure that I understand from the patch how the new system is supposed to work; perhaps you could write a little bit describing it? The main value(?) of separating One point of pedantry; can we call the combined thing something more like options or parameters rather than command line because it would be nice to believe in a world where that config might come from somewhere else. [ Inflammatory, unhelpful suggestion -- maybe we could also include |
Oh yes; for keeping things in sync, there is also the question of the Java tools. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for starting to work on this! Yet I am surprised that #1521 isn't referenced here. Maybe this PR can even go all the way and eventually close that issue?
OPT_VALIDATE \ | ||
OPT_ANSI_C_LANGUAGE \ | ||
"(claim):(show-claims)(floatbv)(all-claims)(all-properties)" // legacy, and will eventually disappear // NOLINT(whitespace/line_length) | ||
const cmdline_definitiont ui_options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A rather unrelated comment: does anyone know why this ever needed to go in the header file? I.e., not just the changes in this PR, but also the current CBMC_OPTIONS
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea :D
optionalt<argumentt> argument, | ||
std::string help_text, | ||
std::string option_group, | ||
optionalt<deprecatedt> deprecated); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it make for a very easy (and IMHO) nice extension to have a second constructor that takes a std::function
for argument parsing (possibly achieving what @LAJW suggested)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That requires a bit more thinking as many options are not independent... I have a few ideas...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Speaking of dependent options: it would actually be nice if one had a way to specify implied options (e.g., --z3
implies --smt2
). But I suppose the wish-list is unbounded (what about conflicting options...) 😇
|
||
cmdline_optiont( | ||
std::string name, | ||
optionalt<argumentt> argument, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should use optionalt
here (or below, for deprecated
), just have multiple constructors with varying numbers of parameters. The optionalt
class members of course still remain in place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, although {}
flows quite intuitively in the initialiser list...
optionalt<argumentt> argument; | ||
std::string help_text; | ||
std::string option_group; | ||
optionalt<deprecatedt> deprecated; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to propose one more member: hidden
. At the moment, we have a number of command-line options that are intentionally undocumented, because either we consider them harmful (such as --no-propagation
) or because they used to be supported and we just don't want to break scripts or other tooling still using them (such as --floatbv
).
Maybe we should actually have a class hierarchy under |
Before I go ahead with this rather big refactoring, I'd like to collect some feedback and additional requirements that you might think of.
a1496e0 is to showcase some of the capabilities.
CI is expected to fail.
Currently, I have the following requirements:
Checklist: