- if (aparser.contains("help") || aparser.contains("h"))
- {
- System.out
- .println("Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n"
- + "-nodisplay\tRun Jalview without User Interface.\n"
- + "-props FILE\tUse the given Jalview properties file instead of users default.\n"
- + "-colour COLOURSCHEME\tThe colourscheme to be applied to the alignment\n"
- + "-annotations FILE\tAdd precalculated annotations to the alignment.\n"
- + "-tree FILE\tLoad the given newick format tree file onto the alignment\n"
- + "-features FILE\tUse the given file to mark features on the alignment.\n"
- + "-fasta FILE\tCreate alignment file FILE in Fasta format.\n"
- + "-clustal FILE\tCreate alignment file FILE in Clustal format.\n"
- + "-pfam FILE\tCreate alignment file FILE in PFAM format.\n"
- + "-msf FILE\tCreate alignment file FILE in MSF format.\n"
- + "-pileup FILE\tCreate alignment file FILE in Pileup format\n"
- + "-pir FILE\tCreate alignment file FILE in PIR format.\n"
- + "-blc FILE\tCreate alignment file FILE in BLC format.\n"
- + "-jalview FILE\tCreate alignment file FILE in Jalview format.\n"
- + "-png FILE\tCreate PNG image FILE from alignment.\n"
- + "-imgMap FILE\tCreate HTML file FILE with image map of PNG image.\n"
- + "-eps FILE\tCreate EPS file FILE from alignment.\n"
- + "-questionnaire URL\tQueries the given URL for information about any Jalview user questionnaires.\n"
- + "-noquestionnaire\tTurn off questionnaire check.\n"
- + "-nousagestats\tTurn off google analytics tracking for this session.\n"
- + "-sortbytree OR -nosortbytree\tEnable or disable sorting of the given alignment by the given tree\n"
- // +
- // "-setprop PROPERTY=VALUE\tSet the given Jalview property, after all other properties files have been read\n\t (quote the 'PROPERTY=VALUE' pair to ensure spaces are passed in correctly)"
- + "-dasserver nickname=URL\tAdd and enable a das server with given nickname\n\t\t\t(alphanumeric or underscores only) for retrieval of features for all alignments.\n"
- + "\t\t\tSources that also support the sequence command may be specified by prepending the URL with sequence:\n"
- + "\t\t\t e.g. sequence:http://localdas.somewhere.org/das/source)\n"
- + "-fetchfrom nickname\tQuery nickname for features for the alignments and display them.\n"
- // +
- // "-vdoc vamsas-document\tImport vamsas document into new session or join existing session with same URN\n"
- // + "-vses vamsas-session\tJoin session with given URN\n"
- + "-groovy FILE\tExecute groovy script in FILE, after all other arguments have been processed (if FILE is the text 'STDIN' then the file will be read from STDIN)\n"
- + "\n~Read documentation in Application or visit http://www.jalview.org for description of Features and Annotations file~\n\n");
- System.exit(0);
- }
- Cache.loadProperties(aparser.getValue("props")); // must do this before
- // anything else!
- String defs = aparser.getValue("setprop");
- while (defs != null)
- {
- int p = defs.indexOf('=');
+ try
+ {
+ String logLevel = null;
+ if (bootstrapArgs.contains(Arg.TRACE))
+ {
+ logLevel = "TRACE";
+ }
+ else if (bootstrapArgs.contains(Arg.DEBUG))
+ {
+ logLevel = bootstrapArgs.getBoolean(Arg.DEBUG) ? "DEBUG" : "INFO";
+ }
+ if (logLevel == null && !(bootstrapProperties == null))
+ {
+ logLevel = bootstrapProperties.getProperty(Cache.JALVIEWLOGLEVEL);
+ }
+ Console.initLogger(logLevel);
+ } catch (NoClassDefFoundError error)
+ {
+ error.printStackTrace();
+ String message = "\nEssential logging libraries not found."
+ + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview";
+ Jalview.exit(message, ExitCode.OK);
+ }
+
+ // register SIGTERM listener
+ Runtime.getRuntime().addShutdownHook(new Thread()
+ {
+ @Override
+ public void run()
+ {
+ Console.debug("Running shutdown hook");
+ QuitHandler.startForceQuit();
+ boolean closeExternal = Cache
+ .getDefault("DEFAULT_CLOSE_EXTERNAL_VIEWERS", false)
+ || Cache.getDefault("ALWAYS_CLOSE_EXTERNAL_VIEWERS", false);
+ StructureViewerBase.setQuitClose(closeExternal);
+ if (desktop != null)
+ {
+ for (JInternalFrame frame : Desktop.desktop.getAllFrames())
+ {
+ if (frame instanceof StructureViewerBase)
+ {
+ ((StructureViewerBase) frame).closeViewer(closeExternal);
+ }
+ }
+ }
+
+ if (QuitHandler.gotQuitResponse() == QResponse.CANCEL_QUIT)
+ {
+ // Got to here by a SIGTERM signal.
+ // Note we will not actually cancel the quit from here -- it's too
+ // late -- but we can wait for saving files and close external viewers
+ // if configured.
+ // Close viewers/Leave viewers open
+ Console.debug("Checking for saving files");
+ QuitHandler.getQuitResponse(false);
+ }
+ else
+ {
+ Console.debug("Nothing more to do");
+ }
+ Console.debug("Exiting, bye!");
+ // shutdownHook cannot be cancelled, JVM will now halt
+ }
+ });
+
+ String usrPropsFile = bootstrapArgs.contains(Arg.PROPS)
+ ? bootstrapArgs.getValue(Arg.PROPS)
+ : aparser.getValue("props");
+ // if usrPropsFile == null, loadProperties will use the Channel
+ // preferences.file
+ Cache.loadProperties(usrPropsFile);
+ if (usrPropsFile != null)
+ {
+ Console.outPrintln(
+ "CMD [-props " + usrPropsFile + "] executed successfully!");
+ testoutput(bootstrapArgs, Arg.PROPS,
+ "test/jalview/bin/testProps.jvprops", usrPropsFile);
+ }
+
+ // --argfile=... -- OVERRIDES ALL NON-BOOTSTRAP ARGS
+ if (bootstrapArgs.contains(Arg.ARGFILE))
+ {
+ argparser = ArgParser.parseArgFiles(
+ bootstrapArgs.getValueList(Arg.ARGFILE),
+ bootstrapArgs.getBoolean(Arg.INITSUBSTITUTIONS),
+ bootstrapArgs);
+ }
+ else
+ {
+ argparser = new ArgParser(args,
+ bootstrapArgs.getBoolean(Arg.INITSUBSTITUTIONS),
+ bootstrapArgs);
+ }
+
+ if (!Platform.isJS())
+ /**
+ * Java only
+ *
+ * @j2sIgnore
+ */
+ {
+ if (bootstrapArgs.contains(Arg.HELP))
+ {
+ List<Map.Entry<Type, String>> helpArgs = bootstrapArgs
+ .getList(Arg.HELP);
+ Console.outPrintln(Arg.usage(helpArgs.stream().map(e -> e.getKey())
+ .collect(Collectors.toList())));
+ Jalview.exit(null, ExitCode.OK);
+ }
+ if (aparser.contains("help") || aparser.contains("h"))
+ {
+ /*
+ * Now using new usage statement.
+ showUsage();
+ */
+ Console.outPrintln(Arg.usage());
+ Jalview.exit(null, ExitCode.OK);
+ }
+
+ // new CLI
+ headlessArg = bootstrapArgs.isHeadless();
+ if (headlessArg)
+ {
+ System.setProperty("java.awt.headless", "true");
+ }
+ // old CLI
+ if (aparser.contains("nodisplay") || aparser.contains("nogui")
+ || aparser.contains("headless"))
+ {
+ System.setProperty("java.awt.headless", "true");
+ headless = true;
+ }
+ // anything else!
+
+ // allow https handshakes to download intermediate certs if necessary
+ System.setProperty("com.sun.security.enableAIAcaIssuers", "true");
+
+ String jabawsUrl = bootstrapArgs.getValue(Arg.JABAWS);
+ if (jabawsUrl == null)
+ jabawsUrl = aparser.getValue("jabaws");
+ if (jabawsUrl != null)
+ {
+ try
+ {
+ Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
+ Console.outPrintln(
+ "CMD [-jabaws " + jabawsUrl + "] executed successfully!");
+ testoutput(bootstrapArgs, Arg.JABAWS,
+ "http://www.compbio.dundee.ac.uk/jabaws", jabawsUrl);
+ } catch (MalformedURLException e)
+ {
+ jalview.bin.Console.errPrintln(
+ "Invalid jabaws parameter: " + jabawsUrl + " ignored");
+ }
+ }
+ }
+
+ List<String> setprops = new ArrayList<>();
+ if (bootstrapArgs.contains(Arg.SETPROP))
+ {
+ setprops = bootstrapArgs.getValueList(Arg.SETPROP);
+ }
+ else
+ {
+ String sp = aparser.getValue("setprop");
+ while (sp != null)
+ {
+ setprops.add(sp);
+ sp = aparser.getValue("setprop");
+ }
+ }
+ for (String setprop : setprops)
+ {
+ int p = setprop.indexOf('=');