From ab54fa42cc7b67c41afde9411f183cac60743071 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Wed, 10 May 2023 12:11:38 +0100 Subject: [PATCH] JAL-629 More docs. Usage statement. Adjust some logging output to respect --quiet. --- .../help/html/features/clarguments-ng-summary.html | 884 +++++++++++++------- help/help/html/features/clarguments-ng.html | 6 +- src/jalview/bin/Cache.java | 4 +- src/jalview/bin/Commands.java | 35 +- src/jalview/bin/Console.java | 7 +- src/jalview/bin/Jalview.java | 98 ++- src/jalview/bin/Launcher.java | 15 + src/jalview/bin/argparser/Arg.java | 382 ++++++--- src/jalview/bin/argparser/ArgParser.java | 10 + src/jalview/bin/argparser/ArgValuesMap.java | 2 + test/jalview/bin/CommandsTest2.java | 6 +- test/jalview/bin/commandsTest2.argfile1 | 2 +- test/jalview/bin/commandsTest2.argfile2 | 2 +- 13 files changed, 945 insertions(+), 508 deletions(-) diff --git a/help/help/html/features/clarguments-ng-summary.html b/help/help/html/features/clarguments-ng-summary.html index ef766b1..c7b5be7 100644 --- a/help/help/html/features/clarguments-ng-summary.html +++ b/help/help/html/features/clarguments-ng-summary.html @@ -9,194 +9,359 @@ * along with Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. --> -Summary of Command Line Arguments (version 2.11.3.0 onwards) +Summary of Command Line Arguments (next generation) -

Summary of Command Line Arguments (version 2.11.3.0 onwards)

+

Summary of Command Line Arguments (next generation)

See Jalview Command Line Arguments (next generation) for more explanation about using Jalview's command line arguments.

+ + + + +

Initialising arguments

+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
argumentactionsubval modifiers (optional)linked (optional)
--open filename/URL ... - Opens one or more alignment files filename or URLs URL in new alignment windows. - Examples. - - - colour=colourscheme, - title=title, - features=featurefile, - annotations=annotationfile, - tree=treefile, - showannotations, - ssannotations, - sortbytree, - wrap - -
--append filename/URL ...Appends one or more alignment files filename or URLs URL to the open alignment window (or opens a new alignment if none already open). - - colour=name, - title=title, - features=featurefile, - annotations=annotationfile, - tree=treefile, - showannotations, - ssannotations, - sortbytree, - wrap - . - Examples. -
--title "string""Specifies the title for the open alignment window as string.
--colour nameApplies the colour scheme name to the open alignment window. Valid values for nameare: - clustal, - blosum62, - pc-identity, - zappo, - taylor, - gecos-flower, - gecos-blossom, - gecos-sunset, - gecos-ocean, - hydrophobic, - helix-propensity, - strand-propensity, - turn-propensity, - buried-index, - nucleotide, - nucleotide-ambiguity, - purine-pyrimidine, - rna-helices, - t-coffee-scores, - sequence-id. - Examples. -
--features filename/URLAdd a feature file filename or URL URL to the open alignment.
argumentaction
--tree filename/URLAdd a tree file filename or URL URL to the open alignment.
--sortbytree / --nosortbytreeEnforces sorting (or not sorting) the alignment in the order of an attached phylogenetic tree.
--annotations filename/URLAdd an annotations file filename or URL URL to the open alignment.
--showannotations / --noshowannotationsEnforces showing (or not showing) alignment annotations.
--wrap / --nowrapEnforces wrapped (or not wrapped) alignment formatting.
‑‑help / -hDisplay a help statement
--structure filename/URLLoad a structure file filename or URL URL associated with a sequence in the open alignment. The sequence to be associated with can be specified with a following --seqid argument, or the subval modifier seqid=ID can be used. A subval INDEX can also be used to specify the INDEX-th sequence in the open alignment. +
‑‑headlessRun Jalview in headless mode. No GUI interface will be created and Jalview will quit after all arguments have been processed.
‑‑jabaws URLSet a different URL to connect to a JABAWS server.
‑‑news / ‑‑nonewsShow (or don't show) the news feed.
‑‑splash / ‑‑nosplashShow (or don't show) the About Jalview splash screen.
‑‑questionnaire / ‑‑noquestionnaireShow (or don't show) the questionnaire if one is available.
‑‑usagestats / ‑‑nousagestatsSend (or don't send) initial launch usage stats. Note: usage stats are useful for future funding for Jalview!
‑‑webservicediscovery / ‑‑nowebservicediscoveryAttempt (or don't attempt) to connect to JABAWS web services.
‑‑props filenameUse file filename as the preferences file instead of the usual ~/.jalview_properties file.
‑‑debugStart Jalview in debug log level.
‑‑quietStop all output to STDOUT (after the Java Virtual Machine has started). Use ‑‑quiet a second time to stop all output to STDERR.
‑‑initsubstitutions / ‑‑noinitsubstitutionsAssume that ‑‑substitutions are initially enabled (or initially disabled).
‑‑jvmmempc=PERCENT + Only available with standalone executable jar or jalview.bin.Launcher. +
+ Limit maximum heap size (memory) to PERCENT% of total physical memory detected. + This defaults to 90 if total physical memory can be detected. +
+ The equals sign ("=") separator must be used with no spaces. +
+ See Memory usage settings for Jalview for more details. +
‑‑jvmmemmax=MAXMEMORY + Only available with standalone executable jar or jalview.bin.Launcher. +
+ Limit maximum heap size (memory) to MAXMEMORY. MAXMEMORY can be specified in bytes, kilobytes(k), megabytes(m), + gigabytes(g) or if you're lucky enough, terabytes(t). + This defaults to 32g if total physical memory can be detected, or to 8g if total physical memory cannot be detected. +
+ The equals sign ("=") separator must be used with no spaces. +
+ See Memory usage settings for Jalview for more details. +
+ + +

Opening an alignment

+ + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + colour=name, +
+ title=string, +
+ features=filename, +
+ annotations=filename, +
+ tree=filename, +
+ showannotations, +
+ showssannotations, +
+ sortbytree, +
+ wrap + . + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
argumentactionsubval modifiers (optional)linked (optional)
‑‑open filename/URL ... + Opens one or more alignment files filename or URLs URL in new alignment windows. + + + colour=name, +
+ title=string, +
+ features=filename, +
+ annotations=filename, +
+ tree=filename, +
+ showannotations, +
+ showssannotations, +
+ sortbytree, +
+ wrap +
+
‑‑append filename/URL ...Appends one or more alignment files filename or URLs URL to the open alignment window (or opens a new alignment if none already open). - seqid=sequenceid or INDEX, - paefile=paefilename, - tempfac=temperature factor type, - ssannotations, - notempfac, - structureviewer=structure viewer -
--seqid IDSpecify the sequence name for the preceding --structure to be associated with.
--paematrix filenameAdd a PAE json matrix file filename to the preceding --structure.
--tempfac nameSet the type of temperature factor. Possible values for name are - default, - plddt -
--structureviewer nameSet the structure viewer to use to open the 3d structure file specified in previous --structure to name. Possible values of name are: -
+
‑‑title "string""Specifies the title for the open alignment window as string.
‑‑colour nameApplies the colour scheme name to the open alignment window. Valid values for name are: +
+ clustal, +
+ blosum62, +
+ pc-identity, +
+ zappo, +
+ taylor, +
+ gecos-flower, +
+ gecos-blossom, +
+ gecos-sunset, +
+ gecos-ocean, +
+ hydrophobic, +
+ helix-propensity, +
+ strand-propensity, +
+ turn-propensity, +
+ buried-index, +
+ nucleotide, +
+ nucleotide-ambiguity, +
+ purine-pyrimidine, +
+ rna-helices, +
+ t-coffee-scores, +
+ sequence-id. +
‑‑features filename/URLAdd a feature file filename or URL URL to the open alignment.
‑‑tree filename/URLAdd a tree file filename or URL URL to the open alignment.
‑‑sortbytree / ‑‑nosortbytreeEnforces sorting (or not sorting) the alignment in the order of an attached phylogenetic tree.
‑‑annotations filename/URLAdd an annotations file filename or URL URL to the open alignment.
‑‑showannotations / ‑‑noshowannotationsEnforces showing (or not showing) alignment annotations.
‑‑wrap / ‑‑nowrapEnforces wrapped (or not wrapped) alignment formatting.
‑‑nostructureDo not open or process any 3D structure in the ‑‑open or ‑‑append files.
+ + +

Adding a 3D structure

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + +
argumentactionsubval modifiers (optional)linked (optional)
‑‑structure filename/URLLoad a structure file filename or URL URL associated with a sequence in the open alignment. The sequence to be associated with can be specified with a following ‑‑seqid argument, or the subval modifier seqid=ID can be used. A subval INDEX can also be used to specify the INDEX-th sequence in the open alignment. + + seqid=id or INDEX, +
+ paefile=filename, +
+ tempfac=name, +
+ showssannotations, +
+ notempfac, +
+ structureviewer=name +
‑‑seqid IDSpecify the sequence name for the preceding ‑‑structure to be associated with.
‑‑paematrix filenameAdd a PAE json matrix file filename to the preceding ‑‑structure.
‑‑tempfac nameSet the type of temperature factor. Valid values for name are: +
+ default, +
+ plddt +
‑‑structureviewer nameSet the structure viewer to use to open the 3d structure file specified in previous ‑‑structure to name. Valid values of name are: +
none,
jmol, @@ -206,125 +371,254 @@ chimerax - requires installation, might need configuring in Preferences,
pymol - requires installation, might need configuring in Preferences -
--notempfacDo not show the temperature factor annotation for the preceding --structure
--groovy filenameProcess a groovy script in the file for the open alignment.
--image new filenameOutput an image of the open alignment window. Format is specified by the subval modifier, a following --type argument or guessed from the file extension. Valid formats/extensions are: - svg, - png, - eps, - html, - biojs - - type=image format, - textrenderer=text format -
--type image formatSet the image format for the preceding --image. Valid values are: - svg, - png, - eps, - html, - biojs -
--textrenderer text formatSets whether text in a vector image format (SVG, HTML, EPS) should be rendered as text or vector line-art. Possible values are: +
‑‑notempfacDo not show the temperature factor annotation for the preceding ‑‑structure
‑‑showssannotations / ‑‑noshowssannotationsDo not show secondary structure annotations for the preceding ‑‑structure
+ + +

Outputting files

+ + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
+ lineart. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
argumentactionsubval modifiers (optional)linked (optional)
‑‑image filenameOutput an image of the open alignment window. Format is specified by the subval modifier, a following ‑‑type argument or guessed from the file extension. Valid formats/extensions are: +
+ svg, +
+ png, +
+ eps, +
+ html, +
+ biojs. +
+ type=name, + textrenderer=name +
‑‑type nameSet the image format for the preceding ‑‑image to name. Valid values for name are: +
+ svg, +
+ png, +
+ eps, +
+ html, +
+ biojs. +
‑‑textrenderer nameSets whether text in a vector image format (SVG, HTML, EPS) should be rendered as text or vector line-art. Valid values for name are: +
text, - lineart -
--output outputfilenameExport the open alignment. Format is specified by the subval modifier, a following --format argument or guessed from the file extension. Valid formats/extensions are: -
- Fasta (fa, fasta), -
- -
-- 
-- 
-- 
‑‑output filenameExport the open alignment to file filename. The format name is specified by the subval modifier format=name, a following ‑‑format name argument or guessed from the file extension. Valid format names (and file extensions) are: +
+ fasta (fa, fasta, mfa, fastq), +
+ pfam (pfam), +
+ stockholm (sto, stk), +
+ pir (pir), +
+ blc (blc), +
+ amsa (amsa), +
+ json (json), +
+ pileup (pileup), +
+ msf (msf), +
+ clustal (aln), +
+ phylip (phy), +
+ jalview (jvp, jar). +
format=name
‑‑format nameSets the format for the preceding ‑‑output file. Valid formats are: +
+ fasta, +
+ pfam, +
+ stockholm, +
+ pir, +
+ blc, +
+ amsa, +
+ json, +
+ pileup, +
+ msf, +
+ clustal, +
+ phylip, +
+ jalview. +
‑‑groovy filenameProcess a groovy script in the file for the open alignment.
‑‑backups / ‑‑nobackupsEnable (or disable) writing backup files when saving an ‑‑output file. This applies to the current open alignment -- to apply to all ‑‑output and ‑‑image files, use after ‑‑all.
‑‑overwrite / ‑‑nooverwriteEnable (or disable) overwriting of output files without backups enabled. This applies to the current open alignment -- to apply to all ‑‑output and ‑‑image files, use after ‑‑all.
‑‑closeClose the current open alignment window. This occurs after other output arguments. This applies to the current open alignment -- to apply to all ‑‑output and ‑‑image files, use after ‑‑all.
+ + +

Controlling flow of arguments

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
argumentactionsubval modifiers (optional)linked (optional)
‑‑newMove on to a new alignment window. This will ensure ‑‑append will start a new alignment window and other linked arguments will apply to the new alignment window.
‑‑substitutions / ‑‑nosubstitutionsThe following argument values allow (or don't allow) subsituting filename parts. This is initially true. Valid substitutions are + {basename} - the filename-without-extension of the currently ‑‑opened file (or first ‑‑appended file), +
+ {dirname}, - the directory (folder) name of the currently ‑‑opened file (or first ‑‑appended file), +
+ {argfilebasename} - the filename-without-extension of the current ‑‑argfile, +
+ {argfiledirname} - the directory (folder) name of the current ‑‑argfile, +
+ {n} - the value of the index counter (starting at 0). +
+ {++n} - increase and substitute the value of the index counter, +
+ {} - the value of the current alignment window default index. +
‑‑argfile filename + Open one or more files filename and read, line-by-line, as arguments to Jalview. +
+ Note that if you use one or more ‑‑argfile arguments then all other non-initialising arguments will be ignored. +
‑‑nppIncrease the index counter used in argument value substitutions.
‑‑allApply the following output arguments to all sets of linked arguments.
‑‑quitAfter all files have been opened, appended and output, quit Jalview. In ‑‑headless mode this already happens.
diff --git a/help/help/html/features/clarguments-ng.html b/help/help/html/features/clarguments-ng.html index a6c91fe..799462b 100644 --- a/help/help/html/features/clarguments-ng.html +++ b/help/help/html/features/clarguments-ng.html @@ -22,7 +22,7 @@ Jalview Command Line Arguments (next generation) -

Jalview Command Line Arguments (version 2.11.3.0 and later)

+

Jalview Command Line Arguments (next generation)

For a summary of Jalview command line arguments see Summary @@ -44,7 +44,7 @@

The old command line arguments can still be used (see the old page on command line arguments) so - existing scripts utilising them should not break. + existing scripts utilising them should not break. These will be removed in a future version of Jalview.

@@ -58,7 +58,7 @@ Note! If you use command line arguments without any dashes and don't use the bare-word argument open then all your arguments will be interpreted as alignment files to be opened by the - new command line argument process. + new command line argument process!

diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 04cf1ec..4df2e0a 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -533,8 +533,8 @@ public class Cache if (orgtimeout == null) { orgtimeout = "30"; - System.out.println("# INFO: Setting default net timeout to " - + orgtimeout + " seconds."); + Console.debug("Setting default net timeout to " + orgtimeout + + " seconds."); } String remoteVersion = null; if (remoteBuildPropertiesUrl.startsWith("http")) diff --git a/src/jalview/bin/Commands.java b/src/jalview/bin/Commands.java index 328c6e1..af4c675 100644 --- a/src/jalview/bin/Commands.java +++ b/src/jalview/bin/Commands.java @@ -309,7 +309,7 @@ public class Commands // Show secondary structure annotations? boolean showSSAnnotations = ArgParser.getFromSubValArgOrPref(avm, - Arg.SSANNOTATIONS, av.getSubVals(), null, + Arg.SHOWSSANNOTATIONS, av.getSubVals(), null, "STRUCT_FROM_PDB", true); af.setAnnotationsVisibility(showSSAnnotations, true, false); @@ -330,33 +330,6 @@ public class Commands af.getCurrentView().getAlignment(), hideThese, null, false, false); } - else - /* - * comment out hacky approach up to here and add this line: if - * (showTemperatureFactor) - */ - { - /* - if (avm.containsArg(Arg.TEMPFAC_LABEL)) - { - AlignmentAnnotation aa = AlignmentUtils - .getFirstSequenceAnnotationOfType( - af.getCurrentView().getAlignment(), - AlignmentAnnotation.LINE_GRAPH); - String label = avm.getValue(Arg.TEMPFAC_LABEL); - if (aa != null) - { - aa.label = label; - } - else - { - Console.info( - "Could not find annotation to apply tempfac_label '" - + label); - } - } - */ - } // store the AlignFrame for this id afMap.put(id, af); @@ -515,7 +488,7 @@ public class Commands // showing annotations from structure file or not boolean ssFromStructure = ArgParser.getFromSubValArgOrPref(avm, - Arg.SSANNOTATIONS, subVals, null, "STRUCT_FROM_PDB", + Arg.SHOWSSANNOTATIONS, subVals, null, "STRUCT_FROM_PDB", true); // get TEMPFAC type from subvals or Arg.TEMPFAC in case user Adds @@ -848,9 +821,9 @@ public class Commands return null; if (subVals != null) { - if (subVals.has("seqid")) + if (subVals.has(Arg.SEQID.getName())) { - seq = al.findName(subVals.get("seqid")); + seq = al.findName(subVals.get(Arg.SEQID.getName())); } else if (-1 < subVals.getIndex() && subVals.getIndex() < al.getSequences().size()) diff --git a/src/jalview/bin/Console.java b/src/jalview/bin/Console.java index b868e7b..ab9ff97 100644 --- a/src/jalview/bin/Console.java +++ b/src/jalview/bin/Console.java @@ -242,8 +242,11 @@ public class Console if (!Platform.isJS()) { - System.err - .println("Setting initial log level to " + logLevel.name()); + if (!Jalview.getInstance().quiet()) + { + System.err.println( + "Setting initial log level to " + logLevel.name()); + } Log4j.init(logLevel); } // log output diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 895268d..09d83ce 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -134,6 +134,17 @@ public class Jalview public static AlignFrame currentAlignFrame; + public ArgParser argparser = null; + + public BootstrapArgs bootstrapArgs = null; + + private boolean QUIET = false; + + public boolean quiet() + { + return QUIET; + } + static { if (!Platform.isJS()) @@ -292,33 +303,15 @@ public class Jalview if (args == null) args = new String[] {}; - // Move any new getdown-launcher-new.jar into place over old - // getdown-launcher.jar - String appdirString = System.getProperty("getdownappdir"); - if (appdirString != null && appdirString.length() > 0) - { - final File appdir = new File(appdirString); - new Thread() - { - @Override - public void run() - { - LaunchUtil.upgradeGetdown( - new File(appdir, "getdown-launcher-old.jar"), - new File(appdir, "getdown-launcher.jar"), - new File(appdir, "getdown-launcher-new.jar")); - } - }.start(); - } - // get args needed before proper ArgParser - BootstrapArgs bootstrapArgs = BootstrapArgs.getBootstrapArgs(args); + bootstrapArgs = BootstrapArgs.getBootstrapArgs(args); if (!Platform.isJS()) { // are we being --quiet ? if (bootstrapArgs.contains(Arg.QUIET)) { + QUIET = true; OutputStream devNull = new OutputStream() { @@ -335,29 +328,56 @@ public class Jalview System.setErr(new PrintStream(devNull)); } } - } - - System.out - .println("Java version: " + System.getProperty("java.version")); - System.out.println("Java Home: " + System.getProperty("java.home")); - System.out.println(System.getProperty("os.arch") + " " - + System.getProperty("os.name") + " " - + System.getProperty("os.version")); - String val = System.getProperty("sys.install4jVersion"); - if (val != null) - { - System.out.println("Install4j version: " + val); + if (bootstrapArgs.contains(Arg.HELP)) + { + QUIET = true; + } } - val = System.getProperty("installer_template_version"); - if (val != null) + + // Move any new getdown-launcher-new.jar into place over old + // getdown-launcher.jar + String appdirString = System.getProperty("getdownappdir"); + if (appdirString != null && appdirString.length() > 0) { - System.out.println("Install4j template version: " + val); + final File appdir = new File(appdirString); + new Thread() + { + @Override + public void run() + { + LaunchUtil.upgradeGetdown( + new File(appdir, "getdown-launcher-old.jar"), + new File(appdir, "getdown-launcher.jar"), + new File(appdir, "getdown-launcher-new.jar")); + } + }.start(); } - val = System.getProperty("launcher_version"); - if (val != null) + + if (!quiet()) { - System.out.println("Launcher version: " + val); + System.out.println( + "Java version: " + System.getProperty("java.version")); + System.out.println("Java Home: " + System.getProperty("java.home")); + System.out.println(System.getProperty("os.arch") + " " + + System.getProperty("os.name") + " " + + System.getProperty("os.version")); + + String val = System.getProperty("sys.install4jVersion"); + if (val != null) + { + System.out.println("Install4j version: " + val); + } + val = System.getProperty("installer_template_version"); + if (val != null) + { + System.out.println("Install4j template version: " + val); + } + val = System.getProperty("launcher_version"); + if (val != null) + { + System.out.println("Launcher version: " + val); + } } if (Platform.isLinux() && LaunchUtils.getJavaVersion() < 11) @@ -441,8 +461,6 @@ public class Jalview "test/jalview/bin/testProps.jvprops", usrPropsFile); } - // new ArgParser - ArgParser argparser; // --argfile=... -- OVERRIDES ALL NON-BOOTSTRAP ARGS if (bootstrapArgs.contains(Arg.ARGFILE)) { diff --git a/src/jalview/bin/Launcher.java b/src/jalview/bin/Launcher.java index dc42f8c..61b87e3 100644 --- a/src/jalview/bin/Launcher.java +++ b/src/jalview/bin/Launcher.java @@ -108,6 +108,21 @@ public class Launcher jvmmemmax = arg.substring( MemorySetting.MAX_HEAPSIZE_PROPERTY_NAME.length() + 2); } + // --doubledash versions + else if (arg.startsWith("--" + + MemorySetting.MAX_HEAPSIZE_PERCENT_PROPERTY_NAME + "=")) + { + jvmmempc = arg.substring( + MemorySetting.MAX_HEAPSIZE_PERCENT_PROPERTY_NAME.length() + + 3); + } + else if (arg.startsWith( + "--" + MemorySetting.MAX_HEAPSIZE_PROPERTY_NAME + "=")) + { + jvmmemmax = arg.substring( + MemorySetting.MAX_HEAPSIZE_PROPERTY_NAME.length() + 3); + } + // retain arg else { arguments.add(arg); diff --git a/src/jalview/bin/argparser/Arg.java b/src/jalview/bin/argparser/Arg.java index d77c075..02584fb 100644 --- a/src/jalview/bin/argparser/Arg.java +++ b/src/jalview/bin/argparser/Arg.java @@ -3,21 +3,190 @@ package jalview.bin.argparser; import java.util.ArrayList; import java.util.Arrays; import java.util.EnumSet; +import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.stream.Collectors; +import jalview.bin.Cache; +import jalview.util.ChannelProperties; + public enum Arg { - HELP("h"), CALCULATION, MENUBAR, STATUS, SHOWOVERVIEW, SHOWANNOTATIONS, - COLOUR("color"), FEATURES, ANNOTATIONS, GROOVY, GROUPS, HEADLESS, JABAWS, - DISPLAY, NEWS, SORTBYTREE, USAGESTATS, APPEND, OPEN, PROPS, QUESTIONNAIRE, - SETPROP, TREE, VDOC, VSESS, OUTPUT, SSANNOTATIONS, NOTEMPFAC, TEMPFAC, - TITLE, PAEMATRIX, WRAP, NOSTRUCTURE, STRUCTURE, STRUCTUREVIEWER, IMAGE, - TYPE, FORMAT, OVERWRITE, TEXTRENDERER, QUIT, CLOSE, DEBUG("d"), TRACE, - QUIET("q"), ARGFILE, NEW, NPP("n++"), SUBSTITUTIONS, INITSUBSTITUTIONS, - NIL, SPLASH, SETARGFILE, UNSETARGFILE, WEBSERVICEDISCOVERY, ALL, BACKUPS, - TESTOUTPUT, SEQID; + + // Initialising arguments (BOOTSTRAP) + HELP("Display this help statement", Opt.UNARY, Opt.BOOTSTRAP), + HEADLESS( + "Run Jalview in headless mode. No GUI interface will be created and Jalview will quit after all arguments have been processed.", + Opt.UNARY, Opt.BOOTSTRAP), + JABAWS("Set a different URL to connect to a JABAWS server.", Opt.STRING, + Opt.BOOTSTRAP), + NEWS("Show (or don't show) the news feed.", true, Opt.BOOLEAN, + Opt.BOOTSTRAP), + SPLASH("Show (or don't show) the About Jalview splash screen.", true, + Opt.BOOLEAN, Opt.BOOTSTRAP), + QUESTIONNAIRE( + "Show (or don't show) the questionnaire if one is available.", + true, Opt.BOOLEAN, Opt.BOOTSTRAP), + USAGESTATS("Send (or don't send) initial launch usage stats.", true, + Opt.BOOLEAN, Opt.BOOTSTRAP), + WEBSERVICEDISCOVERY( + "Attempt (or don't attempt) to connect to JABAWS web services.", + true, Opt.BOOLEAN, Opt.BOOTSTRAP), + PROPS("Use file filename as the preferences file instead of the usual ~/.jalview_properties file.", + Opt.STRING, Opt.BOOTSTRAP), + DEBUG("Start Jalview in debug log level.", Opt.BOOLEAN, Opt.BOOTSTRAP), + TRACE("Start Jalview in trace log level.", Opt.BOOLEAN, Opt.BOOTSTRAP, + Opt.SECRET), + QUIET("Stop all output to STDOUT (after the Java Virtual Machine has started). Use ‑‑quiet a second time to stop all output to STDERR.", + Opt.UNARY, Opt.MULTI, Opt.BOOTSTRAP), + INITSUBSTITUTIONS( + "Assume that ‑‑substitutions are initially enabled (or initially disabled).", + true, Opt.BOOLEAN, Opt.BOOTSTRAP, Opt.NOACTION), + + // Opening an alignment + OPEN("Opens one or more alignment files filename or URLs URL in new alignment windows.", + Opt.STRING, Opt.LINKED, Opt.INCREMENTDEFAULTCOUNTER, Opt.MULTI, + Opt.GLOB, Opt.ALLOWSUBSTITUTIONS, Opt.INPUT), + APPEND("Appends one or more alignment files filename or URLs URL to the open alignment window (or opens a new alignment if none already open).", + Opt.STRING, Opt.LINKED, Opt.MULTI, Opt.GLOB, + Opt.ALLOWSUBSTITUTIONS, Opt.INPUT), + TITLE("Specifies the title for the open alignment window as string.", + Opt.STRING, Opt.LINKED), + COLOUR("Applies the colour scheme to the open alignment window. Valid values are:\n" + + "clustal,\n" + "blosum62,\n" + "pc-identity,\n" + "zappo,\n" + + "taylor,\n" + "gecos-flower,\n" + "gecos-blossom,\n" + + "gecos-sunset,\n" + "gecos-ocean,\n" + "hydrophobic,\n" + + "helix-propensity,\n" + "strand-propensity,\n" + + "turn-propensity,\n" + "buried-index,\n" + "nucleotide,\n" + + "nucleotide-ambiguity,\n" + "purine-pyrimidine,\n" + + "rna-helices,\n" + "t-coffee-scores,\n" + "sequence-id.", + Opt.STRING, Opt.LINKED), + FEATURES("Add a feature file filename or URL URL to the open alignment.", + Opt.STRING, Opt.LINKED, Opt.MULTI, Opt.ALLOWSUBSTITUTIONS), + TREE("Add a tree file filename or URL URL to the open alignment.", + Opt.STRING, Opt.LINKED, Opt.MULTI, Opt.ALLOWSUBSTITUTIONS), + SORTBYTREE( + "Enforces sorting (or not sorting) the alignment in the order of an attached phylogenetic tree.", + true, Opt.LINKED, Opt.BOOLEAN), + ANNOTATIONS( + "Add an annotations file filename or URL URL to the open alignment.", + Opt.STRING, Opt.LINKED, Opt.MULTI, Opt.ALLOWSUBSTITUTIONS), + SHOWANNOTATIONS( + "Enforces showing (or not showing) alignment annotations.", + Opt.BOOLEAN, Opt.LINKED), + WRAP("Enforces wrapped (or not wrapped) alignment formatting.", + Opt.BOOLEAN, Opt.LINKED), + NOSTRUCTURE( + "Do not open or process any 3D structure in the ‑‑open or ‑‑append files.", + Opt.UNARY, Opt.LINKED), + + // Adding a 3D structure + STRUCTURE( + "Load a structure file filename or URL URL associated with a sequence in the open alignment. The sequence to be associated with can be specified with a following --seqid argument, or the subval modifier seqid=ID can be used. A subval INDEX can also be used to specify the INDEX-th sequence in the open alignment.", + Opt.STRING, Opt.LINKED, Opt.MULTI, Opt.ALLOWSUBSTITUTIONS), + SEQID("Specify the sequence name for the preceding --structure to be associated with.", + Opt.STRING, Opt.LINKED, Opt.MULTI, Opt.ALLOWSUBSTITUTIONS), + PAEMATRIX( + "Add a PAE json matrix file filename to the preceding --structure.", + Opt.STRING, Opt.LINKED, Opt.MULTI, Opt.ALLOWSUBSTITUTIONS), + TEMPFAC("Set the type of temperature factor. Possible values for name are default, plddt.", + Opt.STRING, Opt.LINKED), + STRUCTUREVIEWER( + "Set the structure viewer to use to open the 3d structure file specified in previous --structure to name. Possible values of name are:\n" + + "none, jmol, chimera, chimerax, pymol.", + Opt.STRING, Opt.LINKED, Opt.MULTI), + NOTEMPFAC( + "Do not show the temperature factor annotation for the preceding --structure.", + Opt.UNARY, Opt.LINKED), + SHOWSSANNOTATIONS(null, Opt.BOOLEAN, Opt.LINKED), + + // Outputting files + IMAGE("Output an image of the open alignment window. Format is specified by the subval modifier, a following --type argument or guessed from the file extension. Valid formats/extensions are: svg, png, eps, html, biojs.", + Opt.STRING, Opt.LINKED, Opt.ALLOWSUBSTITUTIONS, Opt.ALLOWALL, + Opt.REQUIREINPUT), + TYPE("Set the image format for the preceding --image to name. Valid values for name are: svg, png, eps, html, biojs.", + Opt.STRING, Opt.LINKED, Opt.ALLOWALL), + TEXTRENDERER( + "Sets whether text in a vector image format (SVG, HTML, EPS) should be rendered as text or vector line-art. Possible values for name are: text, lineart.", + Opt.STRING, Opt.LINKED, Opt.ALLOWALL), + OUTPUT("Export the open alignment to file filename. The format name is specified by the subval modifier format=name, a following --format name argument or guessed from the file extension. Valid format names (and file extensions) are:\n" + + "fasta (fa, fasta, mfa, fastq),\n" + "pfam (pfam),\n" + + "stockholm (sto, stk),\n" + "pir (pir),\n" + "blc (blc),\n" + + "amsa (amsa),\n" + "json (json),\n" + "pileup (pileup),\n" + + "msf (msf),\n" + "clustal (aln),\n" + "phylip (phy),\n" + + "jalview (jvp, jar).", Opt.STRING, Opt.LINKED, + Opt.ALLOWSUBSTITUTIONS, Opt.ALLOWALL, Opt.REQUIREINPUT), + FORMAT("Sets the format for the preceding --output file. Valid formats are:\n" + + "fasta,\n" + "pfam,\n" + "stockholm,\n" + "pir,\n" + "blc,\n" + + "amsa,\n" + "json,\n" + "pileup,\n" + "msf,\n" + "clustal,\n" + + "phylip,\n" + "jalview.", Opt.STRING, Opt.LINKED, Opt.ALLOWALL), + GROOVY("Process a groovy script in the file for the open alignment.", + Opt.STRING, Opt.LINKED, Opt.MULTI, Opt.ALLOWSUBSTITUTIONS), + BACKUPS("Enable (or disable) writing backup files when saving an ‑‑output file. This applies to the current open alignment -- to apply to all ‑‑output and ‑‑image files, use after ‑‑all.", + true, Opt.BOOLEAN, Opt.LINKED, Opt.ALLOWALL), + OVERWRITE( + "Enable (or disable) overwriting of output files without backups enabled. This applies to the current open alignment -- to apply to all ‑‑output and ‑‑image files, use after ‑‑all.", + Opt.BOOLEAN, Opt.LINKED, Opt.ALLOWALL), + CLOSE("Close the current open alignment window. This occurs after other output arguments. This applies to the current open alignment -- to apply to all ‑‑output and ‑‑image files, use after ‑‑all.", + Opt.UNARY, Opt.LINKED, Opt.ALLOWALL), + + // controlling flow of arguments + NEW("Move on to a new alignment window. This will ensure --append will start a new alignment window and other linked arguments will apply to the new alignment window.", + Opt.UNARY, Opt.MULTI, Opt.NOACTION, Opt.INCREMENTDEFAULTCOUNTER), + SUBSTITUTIONS( + "The following argument values allow (or don't allow) subsituting filename parts. This is initially true. Valid substitutions are {basename} - the filename-without-extension of the currently --opened file (or first --appended file),\n" + + "{dirname}, - the directory (folder) name of the currently --opened file (or first --appended file),\n" + + "{argfilebasename} - the filename-without-extension of the current --argfile,\n" + + "{argfiledirname} - the directory (folder) name of the current --argfile,\n" + + "{n} - the value of the index counter (starting at 0).\n" + + "{++n} - increase and substitute the value of the index counter,\n" + + "{} - the value of the current alignment window default index.", + true, Opt.BOOLEAN, Opt.MULTI, Opt.NOACTION), + ARGFILE("Open one or more files filename and read, line-by-line, as arguments to Jalview.\n" + + "Note that if you use one or more --argfile arguments then all other non-initialising arguments will be ignored.", + Opt.STRING, Opt.MULTI, Opt.BOOTSTRAP, Opt.GLOB, + Opt.ALLOWSUBSTITUTIONS), + NPP("Increase the index counter used in argument value substitutions.", + Opt.UNARY, Opt.MULTI, Opt.NOACTION), + ALL("Apply the following output arguments to all sets of linked arguments.", + Opt.BOOLEAN, Opt.MULTI, Opt.NOACTION), + QUIT("After all files have been opened, appended and output, quit Jalview. In ‑‑headless mode this already happens.", + Opt.UNARY), + + // secret options + TESTOUTPUT( + "Allow specific stdout information. For testing purposes only.", + Opt.UNARY, Opt.BOOTSTRAP, Opt.SECRET), // do not show this to the user + SETPROP("Set an individual Java System property.", Opt.STRING, Opt.MULTI, + Opt.BOOTSTRAP, Opt.SECRET), // not in use yet + NIL("This argument does nothing on its own, but can be used with linkedIds.", + Opt.UNARY, Opt.LINKED, Opt.MULTI, Opt.NOACTION, Opt.SECRET), + + // private options (inserted during arg processing) + SETARGFILE( + "Sets the current value of the argfilename. Inserted before argfilecontents.", + Opt.UNARY, Opt.LINKED, Opt.STRING, Opt.MULTI, Opt.PRIVATE, + Opt.NOACTION), + UNSETARGFILE( + "Unsets the current value of the argfilename. Inserted after argfile contents.", + Opt.UNARY, Opt.LINKED, Opt.MULTI, Opt.PRIVATE, Opt.NOACTION), + + // these last two have no purpose in the normal Jalview application but are + // used by jalview.bin.Launcher to set memory settings. They are not used by + // argparser but are here for Usage statement reasons. + JVMMEMPC( + "Only available with standalone executable jar or jalview.bin.Launcher.\n" + + "Limit maximum heap size (memory) to PERCENT% of total physical memory detected. This defaults to 90 if total physical memory can be detected.\n" + + "The equals sign (\"=\") separator must be used with no spaces.", + Opt.NOACTION, Opt.BOOTSTRAP, Opt.STRING), + JVMMEMMAX( + "Only available with standalone executable jar or jalview.bin.Launcher.\n" + + "Limit maximum heap size (memory) to MAXMEMORY. MAXMEMORY can be specified in bytes, kilobytes(k), megabytes(m), gigabytes(g) or if you're lucky enough, terabytes(t). This defaults to 32g if total physical memory can be detected, or to 8g if total physical memory cannot be detected.\n" + + "The equals sign (\"=\") separator must be used with no spaces.", + Opt.NOACTION, Opt.BOOTSTRAP, Opt.STRING), + + ; public static enum Opt { @@ -53,6 +222,8 @@ public enum Arg // SubVals and values. PRIVATE, // This Arg is used internally, and cannot be specified by the // user. + SECRET, // This Arg is used by development processes and although it can be + // set by the user, it is not displayed to the user. ALLOWALL, // This Arg can use the '*' linkedId to apply to all known // linkedIds INCREMENTDEFAULTCOUNTER, // If an Arg has this option and the default @@ -63,88 +234,6 @@ public enum Arg // input (i.e. --open or --append) } - static - { - HELP.setOptions("Display this help message", Opt.UNARY, Opt.BOOTSTRAP); - CALCULATION.setOptions(true, Opt.BOOLEAN); // default "true" implies only - // expecting "--nocalculation" - MENUBAR.setOptions(true, Opt.BOOLEAN); - STATUS.setOptions(true, Opt.BOOLEAN); - SHOWOVERVIEW.setOptions(Opt.UNARY, Opt.LINKED); - SHOWANNOTATIONS.setOptions(Opt.BOOLEAN, Opt.LINKED); - COLOUR.setOptions(Opt.STRING, Opt.LINKED); - FEATURES.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI, - Opt.ALLOWSUBSTITUTIONS); - ANNOTATIONS.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI, - Opt.ALLOWSUBSTITUTIONS); - TREE.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI, - Opt.ALLOWSUBSTITUTIONS); - GROOVY.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI, - Opt.ALLOWSUBSTITUTIONS); - GROUPS.setOptions(Opt.STRING, Opt.LINKED); - HEADLESS.setOptions(Opt.UNARY, Opt.BOOTSTRAP); - TESTOUTPUT.setOptions(Opt.UNARY, Opt.BOOTSTRAP); - JABAWS.setOptions(Opt.STRING, Opt.BOOTSTRAP); - DISPLAY.setOptions(true, Opt.BOOLEAN); - NEWS.setOptions(true, Opt.BOOLEAN, Opt.BOOTSTRAP); - SPLASH.setOptions(true, Opt.BOOLEAN, Opt.BOOTSTRAP); - SORTBYTREE.setOptions(true, Opt.LINKED, Opt.BOOLEAN); - QUESTIONNAIRE.setOptions(true, Opt.BOOLEAN, Opt.BOOTSTRAP); - USAGESTATS.setOptions(true, Opt.BOOLEAN, Opt.BOOTSTRAP); - WEBSERVICEDISCOVERY.setOptions(true, Opt.BOOLEAN, Opt.BOOTSTRAP); - APPEND.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI, Opt.GLOB, - Opt.ALLOWSUBSTITUTIONS, Opt.INPUT); - OPEN.setOptions(Opt.STRING, Opt.LINKED, Opt.INCREMENTDEFAULTCOUNTER, - Opt.MULTI, Opt.GLOB, Opt.ALLOWSUBSTITUTIONS, Opt.INPUT); - PROPS.setOptions(Opt.STRING, Opt.BOOTSTRAP); - SETPROP.setOptions(Opt.STRING, Opt.MULTI, Opt.BOOTSTRAP); - - VDOC.setOptions(Opt.UNARY); - VSESS.setOptions(Opt.UNARY); - - OUTPUT.setOptions(Opt.STRING, Opt.LINKED, Opt.ALLOWSUBSTITUTIONS, - Opt.ALLOWALL, Opt.REQUIREINPUT); - - SSANNOTATIONS.setOptions(Opt.BOOLEAN, Opt.LINKED); - NOTEMPFAC.setOptions(Opt.UNARY, Opt.LINKED); - TEMPFAC.setOptions(Opt.STRING, Opt.LINKED); - TITLE.setOptions(Opt.STRING, Opt.LINKED); - PAEMATRIX.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI, - Opt.ALLOWSUBSTITUTIONS); - SEQID.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI, - Opt.ALLOWSUBSTITUTIONS); - NOSTRUCTURE.setOptions(Opt.UNARY, Opt.LINKED); - STRUCTURE.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI, - Opt.ALLOWSUBSTITUTIONS); - STRUCTUREVIEWER.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI); - WRAP.setOptions(Opt.BOOLEAN, Opt.LINKED); - IMAGE.setOptions(Opt.STRING, Opt.LINKED, Opt.ALLOWSUBSTITUTIONS, - Opt.ALLOWALL, Opt.REQUIREINPUT); - TYPE.setOptions(Opt.STRING, Opt.LINKED, Opt.ALLOWALL); - FORMAT.setOptions(Opt.STRING, Opt.LINKED, Opt.ALLOWALL); - TEXTRENDERER.setOptions(Opt.STRING, Opt.LINKED, Opt.ALLOWALL); - QUIT.setOptions(Opt.UNARY); - OVERWRITE.setOptions(Opt.BOOLEAN, Opt.LINKED, Opt.ALLOWALL); - BACKUPS.setOptions(true, Opt.BOOLEAN, Opt.LINKED, Opt.ALLOWALL); - CLOSE.setOptions(Opt.UNARY, Opt.LINKED, Opt.ALLOWALL); - DEBUG.setOptions(Opt.BOOLEAN, Opt.BOOTSTRAP); - TRACE.setOptions(Opt.BOOLEAN, Opt.BOOTSTRAP); - QUIET.setOptions(Opt.UNARY, Opt.MULTI, Opt.BOOTSTRAP); - ARGFILE.setOptions(Opt.STRING, Opt.MULTI, Opt.BOOTSTRAP, Opt.GLOB, - Opt.ALLOWSUBSTITUTIONS); - NEW.setOptions(Opt.UNARY, Opt.MULTI, Opt.NOACTION, - Opt.INCREMENTDEFAULTCOUNTER); - NPP.setOptions(Opt.UNARY, Opt.MULTI, Opt.NOACTION); - SUBSTITUTIONS.setOptions(Opt.BOOLEAN, Opt.MULTI, Opt.NOACTION); - INITSUBSTITUTIONS.setOptions(true, Opt.BOOLEAN, Opt.BOOTSTRAP, - Opt.NOACTION); // defaulting substitutions to true - NIL.setOptions(Opt.UNARY, Opt.LINKED, Opt.MULTI, Opt.NOACTION); - SETARGFILE.setOptions(Opt.STRING, Opt.MULTI, Opt.PRIVATE, Opt.NOACTION); - UNSETARGFILE.setOptions(Opt.MULTI, Opt.PRIVATE, Opt.NOACTION); - ALL.setOptions(Opt.BOOLEAN, Opt.MULTI, Opt.NOACTION); - - } - private final String[] argNames; private Opt[] argOptions; @@ -153,20 +242,32 @@ public enum Arg private String description = null; - private Arg() + private Arg(String description, Opt... options) { - this(new String[0]); + this(null, description, false, options); } - private Arg(String... names) + private Arg(String description, boolean defaultBoolean, Opt... options) { - int length = (names == null || names.length == 0 - || (names.length == 1 && names[0] == null)) ? 1 - : names.length + 1; - this.argNames = new String[length]; - this.argNames[0] = this.getName(); - if (length > 1) - System.arraycopy(names, 0, this.argNames, 1, names.length); + this(null, description, defaultBoolean, options); + } + + private Arg(String alternativeName, String description, Opt... options) + { + this(alternativeName, description, false, options); + } + + private Arg(String alternativeName, String description, + boolean defaultBoolean, Opt... options) + { + this.argNames = alternativeName != null + ? new String[] + { this.getName(), alternativeName } + : new String[] + { this.getName() }; + this.description = description; + this.defaultBoolValue = defaultBoolean; + this.setOptions(options); } public String argString() @@ -238,24 +339,6 @@ public enum Arg protected void setOptions(Opt... options) { - setOptions("", false, options); - } - - protected void setOptions(String desc, Opt... options) - { - setOptions(desc, false, options); - } - - protected void setOptions(boolean defaultBoolValue, Opt... options) - { - setOptions("", defaultBoolValue, options); - } - - protected void setOptions(String desc, boolean defaultBoolValue, - Opt... options) - { - this.description = desc; - this.defaultBoolValue = defaultBoolValue; this.argOptions = options; } @@ -264,11 +347,6 @@ public enum Arg return defaultBoolValue; } - private void setDescription(String d) - { - description = d; - } - protected String getDescription() { return description; @@ -289,14 +367,24 @@ public enum Arg { StringBuilder sb = new StringBuilder(); - sb.append("Usage: jalview [args]"); + sb.append(ChannelProperties.getProperty("app_name")); + String version = Cache.getDefault("VERSION", null); + if (version != null) + { + sb.append(" version "); + sb.append(Cache.getDefault("VERSION", "unknown")); + } + sb.append(System.lineSeparator()); + sb.append("Usage: jalview [files...] [args]"); + sb.append(System.lineSeparator()); sb.append(System.lineSeparator()); int maxArgLength = 0; for (Arg a : EnumSet.allOf(Arg.class)) { - if (a.hasOption(Opt.PRIVATE)) + if (a.hasOption(Opt.PRIVATE) || a.hasOption(Opt.SECRET)) continue; + StringBuilder argSb = new StringBuilder(); argSb.append(a.hasOption(Opt.BOOLEAN) ? booleanArgString(a) : a.argString()); @@ -309,15 +397,34 @@ public enum Arg // might want to sort these for (Arg a : EnumSet.allOf(Arg.class)) { - if (a.hasOption(Opt.PRIVATE)) + if (a.hasOption(Opt.PRIVATE) || a.hasOption(Opt.SECRET)) continue; StringBuilder argSb = new StringBuilder(); argSb.append(a.hasOption(Opt.BOOLEAN) ? booleanArgString(a) : a.argString()); if (a.hasOption(Opt.STRING)) argSb.append("=value"); - sb.append(String.format("%-" + maxArgLength + "s - %s", - argSb.toString(), a.getDescription())); + Iterator descLines = null; + if (a.getDescription() != null) + { + descLines = Arrays.stream(a.getDescription().split("\\n")) + .iterator(); + } + sb.append(String.format("%-" + maxArgLength + "s", argSb.toString())); + boolean first = true; + if (descLines != null) + { + while (descLines.hasNext()) + { + if (first) + sb.append(" - "); + else + sb.append(" ".repeat(maxArgLength + 3)); + sb.append(descLines.next()); + sb.append(System.lineSeparator()); + first = false; + } + } List options = new ArrayList<>(); @@ -347,11 +454,26 @@ public enum Arg options.add("allows substitutions"); } + if (a.hasOption(Opt.PRIVATE)) + { + options.add("for internal use only"); + } + + if (a.hasOption(Opt.SECRET)) + { + options.add("for development use only"); + } + if (options.size() > 0) { - sb.append(" ("); + if (first) + sb.append(" - "); + else + sb.append(" ".repeat(maxArgLength + 3)); + sb.append("("); sb.append(String.join("; ", options)); sb.append(')'); + sb.append(System.lineSeparator()); } sb.append(System.lineSeparator()); } diff --git a/src/jalview/bin/argparser/ArgParser.java b/src/jalview/bin/argparser/ArgParser.java index dd863d1..d551b26 100644 --- a/src/jalview/bin/argparser/ArgParser.java +++ b/src/jalview/bin/argparser/ArgParser.java @@ -846,10 +846,20 @@ public class ArgParser { if (key == null) key = a.getName(); + String nokey = ArgParser.NEGATESTRING + key; if (sv != null && sv.has(key) && sv.get(key) != null) return sv.get(key).toLowerCase(Locale.ROOT).equals("true"); + + if (sv != null && sv.has(key) && sv.get(key) != null) + return sv.get(key).toLowerCase(Locale.ROOT).equals("true"); + + // check for negative boolean (subval "no..." will be "true") + if (sv != null && sv.has(nokey) && sv.get(nokey) != null) + return !sv.get(nokey).toLowerCase(Locale.ROOT).equals("true"); + if (avm != null && avm.containsArg(a)) return avm.getBoolean(a); + return pref != null ? Cache.getDefault(pref, def) : def; } diff --git a/src/jalview/bin/argparser/ArgValuesMap.java b/src/jalview/bin/argparser/ArgValuesMap.java index cbc6faa..340d65a 100644 --- a/src/jalview/bin/argparser/ArgValuesMap.java +++ b/src/jalview/bin/argparser/ArgValuesMap.java @@ -147,6 +147,8 @@ public class ArgValuesMap // specify an id in the subValues so wouldn't need to be guessed). ArgValue closestAv = null; int thisArgIndex = thisAv.getArgIndex(); + if (!containsArg(a)) + return null; ArgValues compareAvs = this.getArgValues(a); int closestNextIndex = Integer.MAX_VALUE; for (ArgValue av : compareAvs.getArgValueList()) diff --git a/test/jalview/bin/CommandsTest2.java b/test/jalview/bin/CommandsTest2.java index 40faccc..a4366c2 100644 --- a/test/jalview/bin/CommandsTest2.java +++ b/test/jalview/bin/CommandsTest2.java @@ -154,7 +154,7 @@ public class CommandsTest2 + "--colour=gecos-flower " + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif " + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json " - + "--nossannotations " + + "--noshowssannotations " + "--props=test/jalview/bin/commandsTest2.jvprops1 ", 15, 4, 1 }, { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa " @@ -168,14 +168,14 @@ public class CommandsTest2 + "--colour=gecos-flower " + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif " + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json " - + "--noshowannotations " + "--nossannotations " + + "--noshowannotations " + "--noshowssannotations " + "--props=test/jalview/bin/commandsTest2.jvprops1 ", 15, 0, 1 }, { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa " + "--colour=gecos-flower " + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif " + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json " - + "--noshowannotations " + "--nossannotations " + + "--noshowannotations " + "--noshowssannotations " + "--props=test/jalview/bin/commandsTest2.jvprops1 ", 15, 0, 1 }, { "--nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --argfile=test/jalview/bin/commandsTest2.argfile1 ", diff --git a/test/jalview/bin/commandsTest2.argfile1 b/test/jalview/bin/commandsTest2.argfile1 index 8a19038..ea3a1be 100644 --- a/test/jalview/bin/commandsTest2.argfile1 +++ b/test/jalview/bin/commandsTest2.argfile1 @@ -1,7 +1,7 @@ --substitutions --append=examples/test_fab41.result/sample.a2m --showannotations ---ssannotations +--showssannotations --colour=gecos-flower --structure=[viewer=jmol,tempfac=plddt,paematrix={dirname}/test_fab41_unrelaxed_rank_1_model_3_scores.json]{dirname}/test_fab41_unrelaxed_rank_1_model_3.pdb --structure={dirname}/test_fab41_unrelaxed_rank_2_model_4.pdb diff --git a/test/jalview/bin/commandsTest2.argfile2 b/test/jalview/bin/commandsTest2.argfile2 index ea7f0bc..1afc69c 100644 --- a/test/jalview/bin/commandsTest2.argfile2 +++ b/test/jalview/bin/commandsTest2.argfile2 @@ -4,7 +4,7 @@ --substitutions --append=examples/test_fab41.result/sample.a2m --noshowannotations ---nossannotations +--noshowssannotations --colour=gecos-flower --structure=[tempfac=plddt,paematrix={dirname}/test_fab41_unrelaxed_rank_1_model_3_scores.json]{dirname}/test_fab41_unrelaxed_rank_1_model_3.pdb --structureviewer=none -- 1.7.10.2