errose28 commented on code in PR #7944:
URL: https://github.com/apache/ozone/pull/7944#discussion_r2271420392
##########
hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/container/ContainerIDParameters.java:
##########
@@ -31,4 +32,34 @@ public class ContainerIDParameters extends ItemsFromStdin {
public void setContainerIDs(List<String> arguments) {
setItems(arguments);
}
+
+ public List<Long> getValidatedIDs() {
+ List<Long> containerIDs = new ArrayList<>(size());
+ boolean allValid = true;
+
+ for (String input: this) {
+ boolean idValid = true;
+ try {
+ long id = Long.parseLong(input);
+ if (id <= 0) {
+ idValid = false;
+ } else {
+ containerIDs.add(id);
+ }
+ } catch (NumberFormatException e) {
+ idValid = false;
+ }
+
+ if (!idValid) {
+ allValid = false;
+ System.err.println("Container ID must be a positive integer, got: " +
input);
+ }
+ }
+
+ // After errors have been printed for all invalid containers, exit PicoCLI
with a non-zero result.
+ if (!allValid) {
+ throw new IllegalArgumentException();
Review Comment:
A message to stderr has already been printed for each invalid container,
this is just to make picoCLI exit after we have finished the list. If we want a
summary message of some kind we could put it here, but the user will get
feedback on each error anyways.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]