Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Commit

Permalink
parse args and validate before any setup
Browse files Browse the repository at this point in the history
Signed-off-by: Sally MacFarlane <[email protected]>
  • Loading branch information
macfarla committed Feb 17, 2020
1 parent 09bdbd0 commit de702f2
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ public boolean parseCommandLine(final String... args) {
}

try {
commandLine.parseWithHandlers(new RunLast().useOut(output), new ExceptionHandler<>(), args);
// parseArgs ensures all args are populated and can then be validated prior to any setup
commandLine.parseArgs(args);

This comment has been minimized.

Copy link
@usmansaleem

usmansaleem Feb 17, 2020

Contributor

is that PicoCli officially mandated technique or is it adapted from Besu code?

This comment has been minimized.

Copy link
@usmansaleem

usmansaleem Feb 17, 2020

Contributor

As per document, parseArgs is the "DIY" set up .... they suggest to use "execute" method instead.

This comment has been minimized.

Copy link
@usmansaleem

This comment has been minimized.

Copy link
@usmansaleem

usmansaleem Feb 17, 2020

Contributor

I still recommend that business validation of cli options occurs in tech/pegasys/ethsigner/SignerSubCommand.java:35 ... which gets executed when picocli finishes populating arguments.

baseCommand.validateOptions(commandLine, LOG);
commandLine.parseWithHandlers(new RunLast().useOut(output), new ExceptionHandler<>(), args);
return true;
} catch (final ParameterException ex) {
handleParameterException(ex);
Expand Down

0 comments on commit de702f2

Please sign in to comment.