Allow not exiting on error, and parse command line from the first argument #84
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #83.
~current:(ref 0)
toArg.parse_argv
, to ensure~argv
is parsed from the beginning each time, in case OMP is linked into a larger process that calls into OMP multiple times.?exit_on_error
to functions that might parse arguments (i.e., act as top-level functions of the driver). The default value is~exit_on_error:true
, which roughly mimics the behavior before this PR. If~exit_on_error:false
is provided, none of the functions ever callexit
. Instead, they raise (leak) the exceptions that would have terminated the process. I decided to add this to all functions because there are three top-level "entry points" intoDriver
, and they call each other, so they all need this change. It is modeled afterAlcotest.run
.This changes the result type of
Driver.run_main
andDriver.run_as_ppx_rewriter
from'a
tounit
, because these functions no longer callexit
in all paths unconditionally.The
exit
behavior is also changed in a few other ways, even with~exit_on_error:true
:run_main
no longer callsexit 0
at its ends, so execution continues in the caller.Arg.Help
, and 1 onArg.Bad
. In the former case, the help message would be printed to STDERR. Now,Arg.Help
always prints to STDOUT, and the exit code is 0, and the exit code forArg.Bad
is always 2. This is in accordance with convention and this code inArg
.