git://source.jalview.org
/
jalview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2ee5edd
)
JAL-629 Firm up bootstrapArgs. Correct '-colour' in test. Separate --headless and...
author
Ben Soares
<b.soares@dundee.ac.uk>
Tue, 28 Feb 2023 18:29:20 +0000
(18:29 +0000)
committer
Ben Soares
<b.soares@dundee.ac.uk>
Tue, 28 Feb 2023 18:29:20 +0000
(18:29 +0000)
src/jalview/bin/ArgParser.java
patch
|
blob
|
history
src/jalview/bin/Commands.java
patch
|
blob
|
history
src/jalview/bin/Jalview.java
patch
|
blob
|
history
test/jalview/bin/CommandLineOperations.java
patch
|
blob
|
history
diff --git
a/src/jalview/bin/ArgParser.java
b/src/jalview/bin/ArgParser.java
index
3dc7921
..
be2c07f
100644
(file)
--- a/
src/jalview/bin/ArgParser.java
+++ b/
src/jalview/bin/ArgParser.java
@@
-878,14
+878,14
@@
public class ArgParser
}
}
}
}
- private static final Collection<String> bootstrapArgs = new ArrayList(
- Arrays.asList("props", "debug"));
+ private static final Collection<Arg> bootstrapArgs = new ArrayList(
+ Arrays.asList(Arg.PROPS, Arg.DEBUG));
- public static Map<String, String> bootstrapArgs(String[] args)
+ public static Map<Arg, String> bootstrapArgs(String[] args)
{
{
- Map<String, String> argMap = new HashMap<>();
+ Map<Arg, String> bootstrapArgMap = new HashMap<>();
if (args == null)
if (args == null)
- return argMap;
+ return bootstrapArgMap;
Enumeration<String> argE = Collections.enumeration(Arrays.asList(args));
while (argE.hasMoreElements())
{
Enumeration<String> argE = Collections.enumeration(Arrays.asList(args));
while (argE.hasMoreElements())
{
@@
-904,10
+904,11
@@
public class ArgParser
{
argName = arg.substring(2);
}
{
argName = arg.substring(2);
}
- if (bootstrapArgs.contains(argName))
- argMap.put(argName, val);
+ Arg a = argMap.get(argName);
+ if (a != null && bootstrapArgs.contains(a))
+ bootstrapArgMap.put(a, val);
}
}
}
}
- return argMap;
+ return bootstrapArgMap;
}
}
\ No newline at end of file
}
}
\ No newline at end of file
diff --git
a/src/jalview/bin/Commands.java
b/src/jalview/bin/Commands.java
index
429c692
..
af8bf65
100644
(file)
--- a/
src/jalview/bin/Commands.java
+++ b/
src/jalview/bin/Commands.java
@@
-60,7
+60,7
@@
public class Commands
{
argParser = ap;
headless = h;
{
argParser = ap;
headless = h;
- boolean argsWereParsed = false;
+ boolean argsWereParsed = true;
if (headless)
{
System.setProperty("java.awt.headless", "true");
if (headless)
{
System.setProperty("java.awt.headless", "true");
@@
-74,13
+74,15
@@
public class Commands
if (id == null)
{
cmds.processUnlinked(id);
if (id == null)
{
cmds.processUnlinked(id);
+ argsWereParsed &= cmds.wereParsed();
}
else
{
cmds.processLinked(id);
}
else
{
cmds.processLinked(id);
+ argsWereParsed &= cmds.wereParsed();
}
cmds.processImages(id);
}
cmds.processImages(id);
- argsWereParsed |= cmds.wereParsed();
+ argsWereParsed &= cmds.wereParsed();
}
}
}
}
@@
-93,7
+95,7
@@
public class Commands
return argsWereParsed;
}
return argsWereParsed;
}
- boolean argsWereParsed = false;
+ boolean argsWereParsed = true; // set false as soon as an arg is found
private boolean wereParsed()
{
private boolean wereParsed()
{
@@
-113,14
+115,16
@@
public class Commands
protected void processUnlinked(String id)
{
protected void processUnlinked(String id)
{
- ArgValuesMap avm = new ArgValuesMap(argParser.linkedArgs(id));
-
processLinked(id);
}
protected void processLinked(String id)
{
ArgValuesMap avm = new ArgValuesMap(argParser.linkedArgs(id));
processLinked(id);
}
protected void processLinked(String id)
{
ArgValuesMap avm = new ArgValuesMap(argParser.linkedArgs(id));
+ if (avm == null)
+ return;
+ else
+ argsWereParsed = false;
/*
// script to execute after all loading is completed one way or another
/*
// script to execute after all loading is completed one way or another
diff --git
a/src/jalview/bin/Jalview.java
b/src/jalview/bin/Jalview.java
index
3cc71af
..
04cf2a3
100755
(executable)
--- a/
src/jalview/bin/Jalview.java
+++ b/
src/jalview/bin/Jalview.java
@@
-282,7
+282,8
@@
public class Jalview
}
// get args needed before proper ArgParser
}
// get args needed before proper ArgParser
- Map<String, String> bootstrapArgs = ArgParser.bootstrapArgs(args);
+ Map<ArgParser.Arg, String> bootstrapArgs = ArgParser
+ .bootstrapArgs(args);
System.out
.println("Java version: " + System.getProperty("java.version"));
System.out
.println("Java version: " + System.getProperty("java.version"));
@@
-314,7
+315,7
@@
public class Jalview
// get bootstrap properties (mainly for the logger level)
Properties bootstrapProperties = Cache
// get bootstrap properties (mainly for the logger level)
Properties bootstrapProperties = Cache
- .bootstrapProperties(bootstrapArgs.get("props"));
+ .bootstrapProperties(bootstrapArgs.get(Arg.PROPS));
// report Jalview version
Cache.loadBuildProperties(true);
// report Jalview version
Cache.loadBuildProperties(true);
@@
-322,11
+323,15
@@
public class Jalview
// old ArgsParser
ArgsParser aparser = new ArgsParser(args);
// old ArgsParser
ArgsParser aparser = new ArgsParser(args);
+ // old
boolean headless = false;
boolean headless = false;
+ // new
+ boolean headlessArg = false;
try
{
try
{
- String logLevel = bootstrapArgs.containsKey("debug") ? "DEBUG" : null;
+ String logLevel = bootstrapArgs.containsKey(Arg.DEBUG) ? "DEBUG"
+ : null;
if (logLevel == null && !(bootstrapProperties == null))
{
logLevel = bootstrapProperties.getProperty(Cache.JALVIEWLOGLEVEL);
if (logLevel == null && !(bootstrapProperties == null))
{
logLevel = bootstrapProperties.getProperty(Cache.JALVIEWLOGLEVEL);
@@
-363,8
+368,8
@@
public class Jalview
}
});
}
});
- String usrPropsFile = bootstrapArgs.containsKey("props")
- ? bootstrapArgs.get("props")
+ String usrPropsFile = bootstrapArgs.containsKey(Arg.PROPS)
+ ? bootstrapArgs.get(Arg.PROPS)
: aparser.getValue("props");
Cache.loadProperties(usrPropsFile);
if (usrPropsFile != null)
: aparser.getValue("props");
Cache.loadProperties(usrPropsFile);
if (usrPropsFile != null)
@@
-376,9
+381,6
@@
public class Jalview
// new ArgParser
ArgParser argparser = new ArgParser(args);
// new ArgParser
ArgParser argparser = new ArgParser(args);
- if (argparser.isSet(Arg.HEADLESS))
- headless = argparser.getBool(Arg.HEADLESS);
-
if (!Platform.isJS())
/**
* Java only
if (!Platform.isJS())
/**
* Java only
@@
-386,20
+388,24
@@
public class Jalview
* @j2sIgnore
*/
{
* @j2sIgnore
*/
{
- if (argparser.isSet(Arg.HEADLESS))
+ if (aparser.contains("help") || aparser.contains("h")
+ || argparser.getBool(Arg.HELP))
{
{
- headless = argparser.getBool(Arg.HEADLESS);
+ showUsage();
+ System.exit(0);
}
}
- if (aparser.contains("help") || aparser.contains("h"))
+ if (argparser.isSet(Arg.HEADLESS))
{
{
- showUsage();
- System.exit(0);
+ System.setProperty("java.awt.headless", "true");
+ // new
+ headlessArg = argparser.getBool(Arg.HEADLESS);
}
}
- if (headless || aparser.contains("nodisplay")
- || aparser.contains("nogui") || aparser.contains("headless"))
+ if (aparser.contains("nodisplay") || aparser.contains("nogui")
+ || aparser.contains("headless"))
{
System.setProperty("java.awt.headless", "true");
{
System.setProperty("java.awt.headless", "true");
+ // old
headless = true;
}
// anything else!
headless = true;
}
// anything else!
@@
-466,7
+472,8
@@
public class Jalview
}
desktop = null;
}
desktop = null;
- setLookAndFeel();
+ if (!(headless || headlessArg))
+ setLookAndFeel();
/*
* configure 'full' SO model if preferences say to, else use the default (full SO)
/*
* configure 'full' SO model if preferences say to, else use the default (full SO)
@@
-478,7
+485,7
@@
public class Jalview
SequenceOntologyFactory.setInstance(new SequenceOntology());
}
SequenceOntologyFactory.setInstance(new SequenceOntology());
}
- if (!headless)
+ if (!(headless || headlessArg))
{
Desktop.nosplash = aparser.contains("nosplash");
desktop = new Desktop();
{
Desktop.nosplash = aparser.contains("nosplash");
desktop = new Desktop();
@@
-605,13
+612,13
@@
public class Jalview
if (commandsSuccess)
{
Console.info("Successfully completed commands");
if (commandsSuccess)
{
Console.info("Successfully completed commands");
- if (headless)
+ if (headlessArg)
System.exit(0);
}
else
{
Console.warn("Error when running commands");
System.exit(0);
}
else
{
Console.warn("Error when running commands");
- if (headless)
+ if (headlessArg)
System.exit(1);
}
System.exit(1);
}
@@
-727,7
+734,7
@@
public class Jalview
if (cs != null)
{
System.out.println(
if (cs != null)
{
System.out.println(
- "CMD [-color " + data + "] executed successfully!");
+ "CMD [-colour " + data + "] executed successfully!");
}
af.changeColour(cs);
}
}
af.changeColour(cs);
}
diff --git
a/test/jalview/bin/CommandLineOperations.java
b/test/jalview/bin/CommandLineOperations.java
index
a9b7640
..
7509ec9
100644
(file)
--- a/
test/jalview/bin/CommandLineOperations.java
+++ b/
test/jalview/bin/CommandLineOperations.java
@@
-53,10
+53,8
@@
public class CommandLineOperations
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
}
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
}
- private static final int TEST_TIMEOUT = 13000; // Note longer timeout needed
- // on
- // full test run than on
- // individual tests
+ // Note longer timeout needed on full test run than on individual tests
+ private static final int TEST_TIMEOUT = 13000;
private static final int SETUP_TIMEOUT = 9500;
private static final int SETUP_TIMEOUT = 9500;
@@
-342,7
+340,7
@@
public class CommandLineOperations
{
return new Object[][] {
// headless mode input operations
{
return new Object[][] {
// headless mode input operations
- { "CMD [-color zappo] executed successfully!",
+ { "CMD [-colour zappo] executed successfully!",
"Failed command : -color zappo" },
{ "CMD [-props test/jalview/bin/testProps.jvprops] executed successfully!",
"Failed command : --props=File" },
"Failed command : -color zappo" },
{ "CMD [-props test/jalview/bin/testProps.jvprops] executed successfully!",
"Failed command : --props=File" },