Use ToolOptions in remaining CLI tools - #4046
Conversation
Signed-off-by: Anish Tilekar <anishtilekar08@gmail.com>
38576d0 to
e67c5a9
Compare
| boolean applyIfSolved = line.hasOption(APPLY_IF_SOLVED_VIOLATIONS); | ||
| boolean isSubTask = line.hasOption(TASK_COUNT); | ||
| ToolOptions options = new ToolOptions(line, context); | ||
| Path caseFile = options.getPath(CASE_FILE).orElseThrow(IllegalStateException::new); |
There was a problem hiding this comment.
for required options throw a missing required option ParseException like in other tools implementation.
| Path caseFile = options.getPath(CASE_FILE).orElseThrow(IllegalStateException::new); | |
| Path caseFile = options.getPath(CASE_FILE).orElseThrow(() -> new ParseException("Missing required option: " + CASE_FILE)); |
Maybe it could be interesting, to handle this option check homogeneously, to have in the ToolOptions class some getRequiredPath, getRequiredValue, getRequiredFloat etc... methods that return the option value or throws this error ? or to add a parameter isRequired in the existing methods (then it would imply a breaking change in tool options usages)
What do you think @olperr1 ?
There was a problem hiding this comment.
and rebase this branch on this one Partharsid:tool-options-conversion-tool once it is merged to also handle th refacto on it
There was a problem hiding this comment.
good call, swapped those over to ParseException with the missing-option message so it matches the rest of the codebase.
also pulled my ConversionTool changes back out since #4047 already covers that file, no point having two PRs fight over it. will rebase this branch once that one lands.
…l changes Signed-off-by: Anish Tilekar <anishtilekar08@gmail.com>
Closes #687.
Went through the list of Tools that Alice pointed out in the issue and switched them over to
ToolOptionsinstead of pulling values straight off theCommandLine. Same behavior everywhere, just less repeatedline.hasOption(...) ? line.getOptionValue(...) : ...boilerplate.Tools updated:
Didn't touch
PluginsInfoToolandVersionTooleven though they were on the list - they don't actually declare any command line options, so there's nothing forToolOptionsto wrap. Happy to add something there if I'm missing the point though.One side effect:
ActionSimulatorToolTestmockedCommandLine.getOptionValue()for the requiredcase-file/dsl-fileoptions but never stubbedhasOption()for them.ToolOptions.getValue()checkshasOption()first, so 3 tests started failing until I added the missing stubs (same pattern already used inSecurityAnalysisToolTest).Ran
mvn teston all the touched modules, everything green, checkstyle happy.