From 135ff4955524fd15e9558364c1e94183f02fd847 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Thu, 11 May 2023 22:25:59 +0100 Subject: [PATCH] JAL-629 Add some shortnames to args. Add Opt.OUTPUT and allow --output=*.ext to be shorthand for --all --output {basename}.ext. --- help/help/html/features/clarguments.html | 4 +-- src/jalview/bin/argparser/Arg.java | 45 ++++++++++++++++++------------ src/jalview/bin/argparser/ArgParser.java | 17 ++++++++++- 3 files changed, 45 insertions(+), 21 deletions(-) diff --git a/help/help/html/features/clarguments.html b/help/help/html/features/clarguments.html index 9a250da..99d4611 100644 --- a/help/help/html/features/clarguments.html +++ b/help/help/html/features/clarguments.html @@ -638,8 +638,8 @@ - ‑‑all - Apply the following output arguments to all sets of linked arguments. + ‑‑all / ‑‑noall + Apply (or stop applying) the following output arguments to all sets of linked arguments. diff --git a/src/jalview/bin/argparser/Arg.java b/src/jalview/bin/argparser/Arg.java index 6fcc011..ba981fb 100644 --- a/src/jalview/bin/argparser/Arg.java +++ b/src/jalview/bin/argparser/Arg.java @@ -15,10 +15,11 @@ public enum Arg { // Initialising arguments (BOOTSTRAP) - HELP("Display this help statement", Opt.UNARY, Opt.BOOTSTRAP), - VERSION("Display the version of " - + ChannelProperties.getProperty("app_name"), Opt.UNARY, - Opt.BOOTSTRAP), + HELP("h", "Display this help statement", Opt.UNARY, Opt.BOOTSTRAP), + VERSION("v", + "Display the version of " + + ChannelProperties.getProperty("app_name"), + 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), @@ -39,10 +40,12 @@ public enum Arg PROPS("Use a file as the preferences file instead of the usual ~/" + ChannelProperties.getProperty("preferences.filename") + " file.", Opt.STRING, Opt.BOOTSTRAP), - DEBUG("Start Jalview in debug log level.", Opt.BOOLEAN, Opt.BOOTSTRAP), + DEBUG("d", "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.", + QUIET("q", + "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( "Set ‑‑substitutions to be initially enabled (or initially disabled).", @@ -65,24 +68,24 @@ public enum Arg + "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), + Opt.STRING, Opt.LINKED, Opt.ALLOWALL), FEATURES("Add a feature file or URL to the open alignment.", Opt.STRING, Opt.LINKED, Opt.MULTI, Opt.ALLOWSUBSTITUTIONS), TREE("Add a tree file or URL to the open alignment.", Opt.STRING, Opt.LINKED, Opt.MULTI, Opt.ALLOWSUBSTITUTIONS), SORTBYTREE( "Enforces sorting (or not sorting) the open alignment in the order of an attached phylogenetic tree.", - true, Opt.LINKED, Opt.BOOLEAN), + true, Opt.LINKED, Opt.BOOLEAN, Opt.ALLOWALL), ANNOTATIONS("Add an annotations file or 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), + Opt.BOOLEAN, Opt.LINKED, Opt.ALLOWALL), WRAP("Enforces wrapped (or not wrapped) alignment formatting.", - Opt.BOOLEAN, Opt.LINKED), + Opt.BOOLEAN, Opt.LINKED, Opt.ALLOWALL), NOSTRUCTURE( "Do not open or process any 3D structure in the ‑‑open or ‑‑append files.", - Opt.UNARY, Opt.LINKED), + Opt.UNARY, Opt.LINKED, Opt.ALLOWALL), // Adding a 3D structure STRUCTURE( @@ -102,15 +105,16 @@ public enum Arg Opt.STRING, Opt.LINKED, Opt.MULTI), NOTEMPFAC( "Do not show the temperature factor annotation for the preceding --structure.", - Opt.UNARY, Opt.LINKED, Opt.SECRET), // keep this secret until it - // works! - SHOWSSANNOTATIONS(null, Opt.BOOLEAN, Opt.LINKED), + Opt.UNARY, Opt.LINKED, Opt.ALLOWALL, Opt.SECRET), // keep this secret + // until it + // works! + SHOWSSANNOTATIONS(null, Opt.BOOLEAN, Opt.LINKED, Opt.ALLOWALL), // 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:\n" + "svg,\n" + "png,\n" + "eps,\n" + "html,\n" + "biojs.", Opt.STRING, Opt.LINKED, Opt.ALLOWSUBSTITUTIONS, Opt.ALLOWALL, - Opt.REQUIREINPUT), + Opt.REQUIREINPUT, Opt.OUTPUT), TYPE("Set the image format for the preceding --image to name. Valid values for name are: svg,\n" + "png,\n" + "eps,\n" + "html,\n" + "biojs.", Opt.STRING, Opt.LINKED, Opt.ALLOWALL), @@ -130,13 +134,15 @@ public enum Arg + "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), + Opt.ALLOWSUBSTITUTIONS, Opt.ALLOWALL, Opt.REQUIREINPUT, + Opt.OUTPUT), 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), + Opt.STRING, Opt.LINKED, Opt.MULTI, Opt.ALLOWSUBSTITUTIONS, + Opt.ALLOWALL), 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( @@ -162,7 +168,8 @@ public enum Arg + "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.", + NPP("n++", + "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), @@ -247,6 +254,8 @@ public enum Arg INPUT, // This Arg counts as an input for REQUIREINPUT REQUIREINPUT, // This Arg can only be applied via --all if there is an // input (i.e. --open or --append) + OUTPUT, // This Arg provides an output filename. With Opt.ALLOWALL *.ext is + // shorthand for --all --output={basename}.ext } private final String[] argNames; diff --git a/src/jalview/bin/argparser/ArgParser.java b/src/jalview/bin/argparser/ArgParser.java index 223cc53..3ca5d3d 100644 --- a/src/jalview/bin/argparser/ArgParser.java +++ b/src/jalview/bin/argparser/ArgParser.java @@ -97,6 +97,10 @@ public class ArgParser // --argfile name private static final String ARGFILEDIRNAME = "{argfiledirname}"; + // an output file wildcard to signify --output=*.ext is really --all --output + // {basename}.ext + private static final String OUTPUTWILDCARD = "*."; + // flag to say whether {n} subtitutions in output filenames should be made. // Turn on and off with --substitutions and --nosubstitutions // Start with it on @@ -393,7 +397,18 @@ public class ArgParser { if (linkedId == null) { - if (allLinkedIds && a.hasOption(Opt.ALLOWALL)) + if (a.hasOption(Opt.OUTPUT) && a.hasOption(Opt.ALLOWALL) + && val.startsWith(OUTPUTWILDCARD)) + { + // --output=*.ext is shorthand for --all --output {basename}.ext + // (or --image=*.ext) + allLinkedIds = true; + linkedId = MATCHALLLINKEDIDS; + String oldval = val; + val = LINKEDIDBASENAME + + val.substring(OUTPUTWILDCARD.length() - 1); + } + else if (allLinkedIds && a.hasOption(Opt.ALLOWALL)) { linkedId = MATCHALLLINKEDIDS; } -- 1.7.10.2