From: Ben Soares Date: Sat, 11 Mar 2023 00:43:01 +0000 (+0000) Subject: JAL-629 Auto and Default count incrementer args. Flags for output filename replacements. X-Git-Tag: Release_2_11_4_0~449 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=2db5d47c785c67cdb7a82b609b3a7eb8af4e7e0c;p=jalview.git JAL-629 Auto and Default count incrementer args. Flags for output filename replacements. --- diff --git a/src/jalview/bin/ArgParser.java b/src/jalview/bin/ArgParser.java index 77b3e87..9af5e4a 100644 --- a/src/jalview/bin/ArgParser.java +++ b/src/jalview/bin/ArgParser.java @@ -42,8 +42,11 @@ public class ArgParser private static final String NEGATESTRING = "no"; - // the linked id used for no id (not even square braces) - private static final String DEFAULTLINKEDID = ""; + // the default linked id prefix used for no id (not even square braces) + private static final String DEFAULTLINKEDIDPREFIX = "JALVIEW:"; + + // the counter added to the default linked id prefix + private int defaultLinkedIdCounter = 0; // the linked id used to increment the idCounter (and use the incremented // value) @@ -76,7 +79,7 @@ public class ArgParser VSESS, OUTPUT, OUTPUTTYPE, SSANNOTATION, NOTEMPFAC, TEMPFAC, TEMPFAC_LABEL, TEMPFAC_DESC, TEMPFAC_SHADING, TITLE, PAEMATRIX, WRAP, NOSTRUCTURE, STRUCTURE, IMAGE, QUIT, CLOSE, DEBUG("d"), QUIET("q"), - ARGFILE; + ARGFILE, INCREMENT, NPP("n++"); static { @@ -132,11 +135,12 @@ public class ArgParser DEBUG.setOptions(Opt.BOOLEAN, Opt.BOOTSTRAP); QUIET.setOptions(Opt.UNARY, Opt.MULTI, Opt.BOOTSTRAP); ARGFILE.setOptions(Opt.STRING, Opt.MULTI, Opt.BOOTSTRAP, Opt.GLOB); + INCREMENT.setOptions(Opt.UNARY, Opt.MULTI); + NPP.setOptions(Opt.UNARY, Opt.MULTI); // BOOTSTRAP args are parsed before a full parse of arguments and // so are accessible at an earlier stage to (e.g.) set debug log level, // provide a props file (that might set log level), run headlessly, read // an argfile instead of other args. - } private final String[] argNames; @@ -579,13 +583,31 @@ public class ArgParser } } + // default and auto counter increments + if (a == Arg.INCREMENT) + { + defaultLinkedIdCounter++; + continue; + } + else if (a == Arg.NPP) + { + idCounter++; + continue; + } + String autoCounterString = null; + boolean usingAutoCounterLinkedId = false; + String defaultLinkedId = new StringBuilder(DEFAULTLINKEDIDPREFIX) + .append(Integer.toString(defaultLinkedIdCounter)) + .toString(); + boolean usingDefaultLinkedId = false; if (a.hasOption(Opt.LINKED)) { if (linkedId == null) { // use default linkedId for linked arguments - linkedId = DEFAULTLINKEDID; + linkedId = defaultLinkedId; + usingDefaultLinkedId = true; Console.debug( "Changing linkedId to '" + linkedId + "' from " + arg); } @@ -594,6 +616,7 @@ public class ArgParser // turn {n} to the autoCounter autoCounterString = Integer.toString(idCounter); linkedId = autoCounterString; + usingAutoCounterLinkedId = true; Console.debug( "Changing linkedId to '" + linkedId + "' from " + arg); } @@ -602,6 +625,7 @@ public class ArgParser // turn {++n} to the incremented autoCounter autoCounterString = Integer.toString(++idCounter); linkedId = autoCounterString; + usingAutoCounterLinkedId = true; Console.debug( "Changing linkedId to '" + linkedId + "' from " + arg); } @@ -665,7 +689,7 @@ public class ArgParser { // allow a default linked id for single usage if (linkedId == null) - linkedId = DEFAULTLINKEDID; + linkedId = defaultLinkedId; // store the order of linkedIds if (linkedOrder == null) linkedOrder = new ArrayList<>();