import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.io.OutputStream;
import java.io.OutputStreamWriter;
+import java.io.PrintStream;
import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.net.URI;
import groovy.lang.Binding;
import groovy.util.GroovyScriptEngine;
import jalview.bin.ArgParser.Arg;
+import jalview.bin.ArgParser.BootstrapArgs;
import jalview.ext.so.SequenceOntology;
import jalview.gui.AlignFrame;
import jalview.gui.Desktop;
private Desktop desktop;
+ protected Commands cmds;
+
public static AlignFrame currentAlignFrame;
static
}
// get args needed before proper ArgParser
- Map<ArgParser.Arg, String> bootstrapArgs = ArgParser
- .bootstrapArgs(args);
+ BootstrapArgs bootstrapArgs = BootstrapArgs.getBootstrapArgs(args);
+
+ if (!Platform.isJS())
+ {
+ // are we being --quiet ?
+ if (bootstrapArgs.contains(Arg.QUIET))
+ {
+ OutputStream devNull = new OutputStream()
+ {
+ @Override
+ public void write(int b)
+ {
+ // DO NOTHING
+ }
+ };
+ System.setOut(new PrintStream(devNull));
+ // redirecting stderr not working
+ if (bootstrapArgs.getList(Arg.QUIET).size() > 1)
+ {
+ System.setErr(new PrintStream(devNull));
+ }
+ }
+ }
System.out
.println("Java version: " + System.getProperty("java.version"));
try
{
- String logLevel = bootstrapArgs.containsKey(Arg.DEBUG) ? "DEBUG"
- : null;
+ String logLevel = bootstrapArgs.contains(Arg.DEBUG) ? "DEBUG" : null;
if (logLevel == null && !(bootstrapProperties == null))
{
logLevel = bootstrapProperties.getProperty(Cache.JALVIEWLOGLEVEL);
}
});
- String usrPropsFile = bootstrapArgs.containsKey(Arg.PROPS)
+ String usrPropsFile = bootstrapArgs.contains(Arg.PROPS)
? bootstrapArgs.get(Arg.PROPS)
: aparser.getValue("props");
Cache.loadProperties(usrPropsFile);
// new ArgParser
ArgParser argparser;
// --argfile=... -- OVERRIDES ALL NON-BOOTSTRAP ARGS
- if (bootstrapArgs.containsKey(Arg.ARGFILE))
+ if (bootstrapArgs.contains(Arg.ARGFILE))
{
- argparser = ArgParser.parseArgFile(bootstrapArgs.get(Arg.ARGFILE));
+ argparser = ArgParser
+ .parseArgFiles(bootstrapArgs.getList(Arg.ARGFILE));
}
else
{
System.exit(0);
}
- if (argparser.isSet(Arg.HEADLESS))
+ if (bootstrapArgs.contains(Arg.HEADLESS))
{
System.setProperty("java.awt.headless", "true");
// new
}
}
// Run Commands from cli
- boolean commandsSuccess = Commands.processArgs(argparser, headlessArg);
+ cmds = new Commands(argparser, headlessArg);
+ boolean commandsSuccess = cmds.argsWereParsed();
if (commandsSuccess)
{
Console.info("Successfully completed commands");
if (headlessArg)
+ {
+ System.out.println("#### EXITING");
System.exit(0);
+ }
}
else
{
if (!Platform.isJS() && !headless && file == null
&& Cache.getDefault("SHOW_STARTUP_FILE", true)
- && !Commands.commandArgsProvided())
+ && !cmds.commandArgsProvided())
// don't open the startup file if command line args have been processed
// (&& !Commands.commandArgsProvided())
/**
public void quit()
{
// System.exit will run the shutdownHook first
+ System.out.println("Quitting now. Bye!");
System.exit(0);
}
{
Jalview.currentAlignFrame = currentAlignFrame;
}
+
+ protected Commands getCommands()
+ {
+ return cmds;
+ }
}