From 1c86d5a94478a2740638b1cf8ddcd043e13e354f Mon Sep 17 00:00:00 2001 From: Keith Armstrong Date: Tue, 7 Jan 2025 15:48:26 -0500 Subject: [PATCH] Redid jcommander code --- src/com/belkast/soap/jCommanderArgs.java | 15 ++++++++++----- src/com/belkast/soap/jCommanderVerifyFile.java | 4 ++-- src/com/belkast/soap/jCommanderVerifyKey.java | 4 ++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/com/belkast/soap/jCommanderArgs.java b/src/com/belkast/soap/jCommanderArgs.java index a11a3c8..fb425ec 100644 --- a/src/com/belkast/soap/jCommanderArgs.java +++ b/src/com/belkast/soap/jCommanderArgs.java @@ -2,17 +2,22 @@ package com.belkast.soap; import com.beust.jcommander.Parameter; +import java.util.ArrayList; +import java.util.List; + public class jCommanderArgs { + @Parameter + private List parameters = new ArrayList<>(); @Parameter(names = "--props" , description = "Location of the properties file", validateWith = jCommanderVerifyFile.class) - public String props; + public String props = "props.conf"; - @Parameter(names = "--key", description = "Encryption Key (must be 16 characters in length)", required = true, password = true, validateWith = jCommanderVerifyKey.class) + @Parameter(names = "--key", description = "Encryption key (must be 16 characters)", required = true, password = true, validateWith = jCommanderVerifyKey.class) public String key; - @Parameter(names = "--encrypt", description = "Value to encrypt using the Encryption Key") + @Parameter(names = "--encrypt", description = "Value to encrypt using the encryption key") public String encrypt; - @Parameter(names = "--debug", description = "Display debug information on the screen (true/false)") - public String debug; + @Parameter(names = "--debug", description = "Display debug information on the screen (no value required)") + public boolean debug = false; } diff --git a/src/com/belkast/soap/jCommanderVerifyFile.java b/src/com/belkast/soap/jCommanderVerifyFile.java index 2a60554..7e56c09 100644 --- a/src/com/belkast/soap/jCommanderVerifyFile.java +++ b/src/com/belkast/soap/jCommanderVerifyFile.java @@ -15,13 +15,13 @@ public class jCommanderVerifyFile implements IParameterValidator boolean success = file.exists(); if (!success) { - throw new ParameterException("Parameter value " + name + " points to a file that does not exist : " + value); + throw new ParameterException("Parameter value for " + name + " specifies a file that does not exist : " + value); } } catch (ParameterException ex) { - System.out.println(); System.out.println(ex.toString()); + System.out.println(); System.exit(0); } } diff --git a/src/com/belkast/soap/jCommanderVerifyKey.java b/src/com/belkast/soap/jCommanderVerifyKey.java index 9aa11f3..d99e11c 100644 --- a/src/com/belkast/soap/jCommanderVerifyKey.java +++ b/src/com/belkast/soap/jCommanderVerifyKey.java @@ -10,13 +10,13 @@ public class jCommanderVerifyKey implements IParameterValidator { try { int n = value.length(); if (n != 16) { - throw new ParameterException("Parameter value " + name + " must have a length of 16 characters!"); + throw new ParameterException("Parameter value for " + name + " must have a length of 16 characters!"); } } catch (ParameterException ex) { - System.out.println(); System.out.println(ex.toString()); + System.out.println(); System.exit(0); } }