+
+ protected Commands getCommands()
+ {
+ return cmds;
+ }
+
+ public static void exit(String message, int exitcode)
+ {
+ if (Console.log == null)
+ {
+ // Don't start the logger just to exit!
+ if (message != null)
+ {
+ if (exitcode == 0)
+ {
+ System.out.println(message);
+ }
+ else
+ {
+ System.err.println(message);
+ }
+ }
+ }
+ else
+ {
+ Console.debug("Using Jalview.exit");
+ if (message != null)
+ {
+ if (exitcode == 0)
+ {
+ Console.info(message);
+ }
+ else
+ {
+ Console.error(message);
+ }
+ }
+ }
+ if (exitcode > -1)
+ {
+ System.exit(exitcode);
+ }
+ }
+
+ /*
+ * testoutput for string values
+ */
+ protected static void testoutput(ArgParser ap, Arg a, String s1,
+ String s2)
+ {
+ BootstrapArgs bsa = ap.getBootstrapArgs();
+ if (!bsa.getBoolean(Arg.TESTOUTPUT))
+ return;
+ if (!((s1 == null && s2 == null) || (s1 != null && s1.equals(s2))))
+ {
+ Console.debug("testoutput with unmatching values '" + s1 + "' and '"
+ + s2 + "' for arg " + a.argString());
+ return;
+ }
+ boolean isset = a.hasOption(Opt.BOOTSTRAP) ? bsa.contains(a)
+ : ap.isSet(a);
+ if (!isset)
+ {
+ Console.warn("Arg '" + a.getName() + "' not set at all");
+ return;
+ }
+ testoutput(true, a, s1, s2);
+ }
+
+ protected static void testoutput(BootstrapArgs bsa, Arg a, String s1,
+ String s2)
+ {
+ if (!bsa.getBoolean(Arg.TESTOUTPUT))
+ return;
+ if (!((s1 == null && s2 == null) || (s1 != null && s1.equals(s2))))
+ {
+ Console.debug("testoutput with unmatching values '" + s1 + "' and '"
+ + s2 + "' for arg " + a.argString());
+ return;
+ }
+ if (!a.hasOption(Opt.BOOTSTRAP))
+ {
+ Console.error("Non-bootstrap Arg '" + a.getName()
+ + "' given to testoutput(BootstrapArgs bsa, Arg a, String s1, String s2) with only BootstrapArgs");
+ }
+ if (!bsa.contains(a))
+ {
+ Console.warn("Arg '" + a.getName() + "' not set at all");
+ return;
+ }
+ testoutput(true, a, s1, s2);
+ }
+
+ private static void testoutput(boolean yes, Arg a, String s1, String s2)
+ {
+ if (yes && ((s1 == null && s2 == null)
+ || (s1 != null && s1.equals(s2))))
+ {
+ System.out.println("[TESTOUTPUT] arg " + a.argString() + "='" + s1
+ + "' was set");
+ }
+ }
+
+ /*
+ * testoutput for boolean values
+ */
+ protected static void testoutput(ArgParser ap, Arg a)
+ {
+ if (ap == null)
+ return;
+ BootstrapArgs bsa = ap.getBootstrapArgs();
+ if (bsa == null)
+ return;
+ if (!bsa.getBoolean(Arg.TESTOUTPUT))
+ return;
+ boolean val = a.hasOption(Opt.BOOTSTRAP) ? bsa.getBoolean(a)
+ : ap.getBoolean(a);
+ boolean isset = a.hasOption(Opt.BOOTSTRAP) ? bsa.contains(a)
+ : ap.isSet(a);
+ if (!isset)
+ {
+ Console.warn("Arg '" + a.getName() + "' not set at all");
+ return;
+ }
+ testoutput(val, a);
+ }
+
+ protected static void testoutput(BootstrapArgs bsa, Arg a)
+ {
+ if (!bsa.getBoolean(Arg.TESTOUTPUT))
+ return;
+ if (!a.hasOption(Opt.BOOTSTRAP))
+ {
+ Console.warn("Non-bootstrap Arg '" + a.getName()
+ + "' given to testoutput(BootstrapArgs bsa, Arg a) with only BootstrapArgs");
+
+ }
+ if (!bsa.contains(a))
+ {
+ Console.warn("Arg '" + a.getName() + "' not set at all");
+ return;
+ }
+ testoutput(bsa.getBoolean(a), a);
+ }
+
+ private static void testoutput(boolean yes, Arg a)
+ {
+ System.out.println("[TESTOUTPUT] arg "
+ + (yes ? a.argString() : a.negateArgString()) + " was set");
+ }