From 96b2b15303c2c7b075eb2dee5a84b6b04ef1a335 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Sat, 11 Mar 2023 12:45:18 +0000 Subject: [PATCH] JAL-629 --substitutions --nosubstitutions flags, --nil[{++n}] just in case needed --- src/jalview/bin/ArgParser.java | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/jalview/bin/ArgParser.java b/src/jalview/bin/ArgParser.java index 9af5e4a..dfd3457 100644 --- a/src/jalview/bin/ArgParser.java +++ b/src/jalview/bin/ArgParser.java @@ -57,10 +57,14 @@ public class ArgParser private int idCounter = 0; + // flag to say whether {n} subtitutions in output filenames should be made. + // Turn on and off with --subs and --nosubs + private boolean substitutions = false; + private static enum Opt { BOOLEAN, STRING, UNARY, MULTI, LINKED, NODUPLICATEVALUES, BOOTSTRAP, - GLOB + GLOB, NOACTION } public enum Arg @@ -79,7 +83,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, INCREMENT, NPP("n++"); + ARGFILE, INCREMENT, NPP("n++"), SUBSTITUTIONS, NIL; static { @@ -135,8 +139,10 @@ 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); + INCREMENT.setOptions(Opt.UNARY, Opt.MULTI, Opt.NOACTION); + NPP.setOptions(Opt.UNARY, Opt.MULTI, Opt.NOACTION); + SUBSTITUTIONS.setOptions(Opt.BOOLEAN, Opt.MULTI, Opt.NOACTION); + NIL.setOptions(Opt.UNARY, Opt.LINKED, Opt.MULTI, Opt.NOACTION); // 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 @@ -583,16 +589,19 @@ public class ArgParser } } + // make NOACTION adjustments // default and auto counter increments if (a == Arg.INCREMENT) { defaultLinkedIdCounter++; - continue; } else if (a == Arg.NPP) { idCounter++; - continue; + } + else if (a == Arg.SUBSTITUTIONS) + { + substitutions = !negated; } String autoCounterString = null; @@ -634,6 +643,10 @@ public class ArgParser if (!linkedArgs.containsKey(linkedId)) linkedArgs.put(linkedId, new ArgValuesMap()); + // do not continue for NOACTION args + if (a.hasOption(Opt.NOACTION)) + continue; + ArgValuesMap avm = linkedArgs.get(linkedId); // not dealing with both NODUPLICATEVALUES and GLOB -- 1.7.10.2