+ String message = Arg.ARGFILE.argString() + "=\"" + argFile.getPath()
+ + "\": File could not be read.";
+ Jalview.exit(message, ExitCode.FILE_NOT_READABLE);
+ }
+ }
+ // Third param "true" uses Opt.PRIVATE args --setargile=argfile and
+ // --unsetargfile
+ return new ArgParser(argsList, initsubstitutions, true, bsa);
+ }
+
+ protected static List<String> readArgFile(File argFile)
+ {
+ List<String> args = new ArrayList<>();
+ if (argFile != null && argFile.exists())
+ {
+ try
+ {
+ for (String line : Files.readAllLines(Paths.get(argFile.getPath())))
+ {
+ if (line != null && line.length() > 0
+ && line.charAt(0) != ARGFILECOMMENT)
+ args.add(line);
+ }
+ } catch (IOException e)
+ {
+ String message = Arg.ARGFILE.argString() + "=\"" + argFile.getPath()
+ + "\": File could not be read.";
+ Console.debug(message, e);
+ Jalview.exit(message, ExitCode.FILE_NOT_READABLE);
+ }
+ }
+ return args;
+ }
+
+ // the following methods look for the "*" linkedId and add the argvalue to all
+ // linkedId ArgValues if it does.
+ /**
+ * This version inserts the subvals sv into all created values
+ */
+ private void addValue(String linkedId, String givenLinkedId, Type type,
+ ArgValues avs, SubVals sv, String v, int argIndex, boolean doSubs)
+ {
+ this.argValueOperation(Op.ADDVALUE, linkedId, givenLinkedId, type, avs,
+ sv, v, false, argIndex, doSubs);
+ }
+
+ private void setBoolean(String linkedId, String givenLinkedId, Type type,
+ ArgValues avs, boolean b, int argIndex)
+ {
+ this.argValueOperation(Op.SETBOOLEAN, linkedId, givenLinkedId, type,
+ avs, null, null, b, argIndex, false);
+ }
+
+ private void setNegated(String linkedId, ArgValues avs, boolean b)
+ {
+ this.argValueOperation(Op.SETNEGATED, linkedId, null, null, avs, null,
+ null, b, 0, false);
+ }
+
+ private void incrementCount(String linkedId, ArgValues avs)
+ {
+ this.argValueOperation(Op.INCREMENTCOUNT, linkedId, null, null, avs,
+ null, null, false, 0, false);
+ }
+
+ private enum Op
+ {
+ ADDVALUE, SETBOOLEAN, SETNEGATED, INCREMENTCOUNT
+ }
+
+ private void argValueOperation(Op op, String linkedId,
+ String givenLinkedId, Type type, ArgValues avs, SubVals sv,
+ String v, boolean b, int argIndex, boolean doSubs)
+ {
+ // default to merge subvals if subvals are provided
+ argValueOperation(op, linkedId, givenLinkedId, type, avs, sv, true, v,
+ b, argIndex, doSubs);
+ }
+
+ /**
+ * The following operations look for the "*" and "open*" linkedIds and add the
+ * argvalue to all appropriate linkedId ArgValues if it does. If subvals are
+ * supplied, they are inserted into all new set values.
+ *
+ * @param op
+ * The ArgParser.Op operation
+ * @param linkedId
+ * The String linkedId from the ArgValuesMap
+ * @param type
+ * The Arg.Type to attach to this ArgValue
+ * @param avs
+ * The ArgValues for this linkedId
+ * @param sv
+ * Use these SubVals on the ArgValue
+ * @param merge
+ * Merge the SubVals with any existing on the value. False will
+ * replace unless sv is null
+ * @param v
+ * The value of the ArgValue (may contain subvals).
+ * @param b
+ * The boolean value of the ArgValue.
+ * @param argIndex
+ * The argIndex for the ArgValue.
+ * @param doSubs
+ * Whether to perform substitutions on the subvals and value.
+ */
+ private void argValueOperation(Op op, String linkedId,
+ String givenLinkedId, Type type, ArgValues avs, SubVals sv,
+ boolean merge, String v, boolean b, int argIndex, boolean doSubs)
+ {
+ Arg a = avs.arg();
+
+ List<String> wildcardLinkedIds = null;
+ if (a.hasOption(Opt.ALLOWMULTIID))
+ {
+ switch (linkedId)
+ {
+ case MATCHALLLINKEDIDS:
+ wildcardLinkedIds = getLinkedIds();
+ break;
+ case MATCHOPENEDLINKEDIDS:
+ wildcardLinkedIds = this.storedLinkedIds;
+ break;