Redid jcommander code

This commit is contained in:
Keith Armstrong 2025-01-07 15:48:26 -05:00
parent 7ea1f88238
commit 1c86d5a944
3 changed files with 14 additions and 9 deletions

View File

@ -2,17 +2,22 @@ package com.belkast.soap;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;
import java.util.ArrayList;
import java.util.List;
public class jCommanderArgs { public class jCommanderArgs {
@Parameter
private List<String> parameters = new ArrayList<>();
@Parameter(names = "--props" , description = "Location of the properties file", validateWith = jCommanderVerifyFile.class) @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; 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; public String encrypt;
@Parameter(names = "--debug", description = "Display debug information on the screen (true/false)") @Parameter(names = "--debug", description = "Display debug information on the screen (no value required)")
public String debug; public boolean debug = false;
} }

View File

@ -15,13 +15,13 @@ public class jCommanderVerifyFile implements IParameterValidator
boolean success = file.exists(); boolean success = file.exists();
if (!success) 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) catch (ParameterException ex)
{ {
System.out.println();
System.out.println(ex.toString()); System.out.println(ex.toString());
System.out.println();
System.exit(0); System.exit(0);
} }
} }

View File

@ -10,13 +10,13 @@ public class jCommanderVerifyKey implements IParameterValidator {
try { try {
int n = value.length(); int n = value.length();
if (n != 16) { 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) catch (ParameterException ex)
{ {
System.out.println();
System.out.println(ex.toString()); System.out.println(ex.toString());
System.out.println();
System.exit(0); System.exit(0);
} }
} }