git://source.jalview.org
/
jalview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
JAL-629 Fixed appending URLs
[jalview.git]
/
src
/
jalview
/
bin
/
argparser
/
BootstrapArgs.java
diff --git
a/src/jalview/bin/argparser/BootstrapArgs.java
b/src/jalview/bin/argparser/BootstrapArgs.java
index
0d648a4
..
4829ef8
100644
(file)
--- a/
src/jalview/bin/argparser/BootstrapArgs.java
+++ b/
src/jalview/bin/argparser/BootstrapArgs.java
@@
-1,10
+1,13
@@
package jalview.bin.argparser;
package jalview.bin.argparser;
+import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import jalview.bin.argparser.Arg.Opt;
import jalview.util.FileUtils;
import jalview.bin.argparser.Arg.Opt;
import jalview.util.FileUtils;
@@
-14,6
+17,8
@@
public class BootstrapArgs
// only need one
private Map<Arg, List<String>> bootstrapArgMap = new HashMap<>();
// only need one
private Map<Arg, List<String>> bootstrapArgMap = new HashMap<>();
+ private Set<File> argFiles = new HashSet<>();
+
public static BootstrapArgs getBootstrapArgs(String[] args)
{
List<String> argList = new ArrayList<>(Arrays.asList(args));
public static BootstrapArgs getBootstrapArgs(String[] args)
{
List<String> argList = new ArrayList<>(Arrays.asList(args));
@@
-22,13
+27,25
@@
public class BootstrapArgs
private BootstrapArgs(List<String> args)
{
private BootstrapArgs(List<String> args)
{
- parse(args);
+ parse(args, null);
}
}
- private void parse(List<String> args)
+ private void parse(List<String> args, File inArgFile)
{
if (args == null)
return;
{
if (args == null)
return;
+ // avoid looping argFiles
+ if (inArgFile != null)
+ {
+ if (argFiles.contains(inArgFile))
+ {
+ System.err.println(
+ "Looped argfiles detected: '" + inArgFile.getPath() + "'");
+ return;
+ }
+ argFiles.add(inArgFile);
+ }
+
for (int i = 0; i < args.size(); i++)
{
String arg = args.get(i);
for (int i = 0; i < args.size(); i++)
{
String arg = args.get(i);
@@
-69,17
+86,32
@@
public class BootstrapArgs
if (a.hasOption(Opt.STRING))
{
if (a.hasOption(Opt.STRING))
{
+ List<String> vals = null;
if (equalPos == -1)
{
if (equalPos == -1)
{
- addAll(a, ArgParser.getShellGlobbedFilenameValues(a, args,
- i + 1));
+ vals = ArgParser.getShellGlobbedFilenameValues(a, args, i + 1);
}
else
{
if (a.hasOption(Opt.GLOB))
}
else
{
if (a.hasOption(Opt.GLOB))
- addAll(a, FileUtils.getFilenamesFromGlob(val));
+ {
+ vals = FileUtils.getFilenamesFromGlob(val);
+ }
else
else
- add(a, val);
+ {
+ vals = new ArrayList<>();
+ vals.add(val);
+ }
+ }
+ addAll(a, vals);
+
+ if (a == Arg.ARGFILE)
+ {
+ for (String filename : vals)
+ {
+ File argFile = new File(filename);
+ parse(ArgParser.readArgFile(argFile), argFile);
+ }
}
}
else
}
}
else
@@
-138,6
+170,10
@@
public class BootstrapArgs
{
l.addAll(al);
}
{
l.addAll(al);
}
+ else if (l.size() == 0 && al.size() > 0)
+ {
+ l.add(al.get(0));
+ }
}
/*
}
/*