JAL-629 Changed --newframe and --allframes to --new and --all. More consistent -...
[jalview.git] / src / jalview / bin / argparser / Arg.java
index f712010..a5c344d 100644 (file)
@@ -11,16 +11,55 @@ public enum Arg
 {
   HELP("h"), CALCULATION, MENUBAR, STATUS, SHOWOVERVIEW, ANNOTATIONS,
   COLOUR, FEATURES, GROOVY, GROUPS, HEADLESS, JABAWS, DISPLAY, GUI, NEWS,
-  SORTBYTREE, USAGESTATS, OPEN, OPENNEW, PROPS, QUESTIONNAIRE, SETPROP,
-  TREE, VDOC, VSESS, OUTPUT, OUTPUTTYPE, SSANNOTATIONS, NOTEMPFAC, TEMPFAC,
-  TITLE, PAEMATRIX, WRAP, NOSTRUCTURE, STRUCTURE, STRUCTUREVIEWER, IMAGE,
-  QUIT, CLOSE, DEBUG("d"), QUIET("q"), ARGFILE, INCREMENT, NPP("n++"),
-  SUBSTITUTIONS, INITSUBSTITUTIONS, NIL, SPLASH, SETARGFILE, UNSETARGFILE;
+  SORTBYTREE, USAGESTATS, APPEND, OPEN, PROPS, QUESTIONNAIRE, SETPROP, TREE,
+  VDOC, VSESS, OUTPUT, SSANNOTATIONS, NOTEMPFAC, TEMPFAC, TITLE, PAEMATRIX,
+  WRAP, NOSTRUCTURE, STRUCTURE, STRUCTUREVIEWER, IMAGE, TYPE, RENDERER,
+  QUIT, CLOSE, DEBUG("d"), QUIET("q"), ARGFILE, NEW, NPP("n++"),
+  SUBSTITUTIONS, INITSUBSTITUTIONS, NIL, SPLASH, SETARGFILE, UNSETARGFILE,
+  WEBSERVICEDISCOVERY, ALL;
 
   protected static enum Opt
   {
-    BOOLEAN, STRING, UNARY, MULTI, LINKED, NODUPLICATEVALUES, BOOTSTRAP,
-    GLOB, NOACTION, ALLOWSUBSTITUTIONS, PRIVATE
+    BOOLEAN, // This Arg can be specified as --arg or --noarg to give true or
+             // false. A default can be given with setOptions(bool, Opt....).
+             // Use ArgParser.isSet(Arg) to see if this arg was not specified.
+    STRING, // This Arg can accept a value either through --arg=value or --arg
+            // value.
+    UNARY, // This Arg is a boolean value, true if present, false if not. Like
+           // BOOLEAN but without the --noarg option.
+    MULTI, // This Arg can be specified multiple times. Multiple values are
+           // stored in the ArgValuesMap (along with their positional index) for
+           // each linkedId.
+    LINKED, // This Arg can be linked to others through a --arg[linkedId] or
+            // --arg[linkedId]=value. If no linkedId is specified then the
+            // current default linkedId will be used.
+    NODUPLICATEVALUES, // This Arg can only have one value (per linkedId). The
+                       // first value will be used and subsequent values ignored
+                       // with a warning.
+    BOOTSTRAP, // This Arg value(s) can be determined at an earlier stage than
+               // non-BOOTSTRAP Args. Substitutions do not happen in BOOTSTRAP
+               // Args and they cannot be linked or contain SubVals. See
+               // jalview.bin.argparser.BootstrapArgs.
+    GLOB, // This Arg can expand wildcard filename "globs" (e.g.
+          // path/*/filename*). If the Arg value is given as --arg filename*
+          // then the shell will have expanded the glob already, but if
+          // specified as --arg=filename* then the Java glob expansion method
+          // will be used (see FileUtils.getFilenamesFromGlob()). Note that this
+          // might be different from the shell expansion rules.
+    NOACTION, // This Arg does not perform a data task, usually used to control
+              // flow in ArgParser.parse(args).
+    ALLOWSUBSTITUTIONS, // This Arg allows substitutions in its linkedId,
+                        // SubVals and values.
+    PRIVATE, // This Arg is used internally, and cannot be specified by 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
+                             // linkedId is used, the defaultLinkedIdCounter is
+                             // incremented *first*.
+    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)
   }
 
   static
@@ -47,10 +86,10 @@ public enum Arg
     // expects a string value
     SORTBYTREE.setOptions(true, Opt.BOOLEAN);
     USAGESTATS.setOptions(true, Opt.BOOLEAN);
-    OPEN.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI, Opt.GLOB,
-            Opt.ALLOWSUBSTITUTIONS);
-    OPENNEW.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI, Opt.GLOB,
-            Opt.ALLOWSUBSTITUTIONS);
+    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);
     QUESTIONNAIRE.setOptions(Opt.BOOLEAN, Opt.BOOTSTRAP);
     SETPROP.setOptions(Opt.STRING, Opt.MULTI, Opt.BOOTSTRAP);
@@ -59,8 +98,8 @@ public enum Arg
     VDOC.setOptions(Opt.UNARY);
     VSESS.setOptions(Opt.UNARY);
 
-    OUTPUT.setOptions(Opt.STRING, Opt.LINKED, Opt.ALLOWSUBSTITUTIONS);
-    OUTPUTTYPE.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI);
+    OUTPUT.setOptions(Opt.STRING, Opt.LINKED, Opt.ALLOWSUBSTITUTIONS,
+            Opt.ALLOWALL, Opt.REQUIREINPUT);
 
     SSANNOTATIONS.setOptions(Opt.BOOLEAN, Opt.LINKED);
     NOTEMPFAC.setOptions(Opt.UNARY, Opt.LINKED);
@@ -73,25 +112,27 @@ public enum Arg
             Opt.ALLOWSUBSTITUTIONS);
     STRUCTUREVIEWER.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI);
     WRAP.setOptions(Opt.BOOLEAN, Opt.LINKED);
-    IMAGE.setOptions(Opt.STRING, Opt.LINKED, Opt.ALLOWSUBSTITUTIONS);
+    IMAGE.setOptions(Opt.STRING, Opt.LINKED, Opt.ALLOWSUBSTITUTIONS,
+            Opt.ALLOWALL, Opt.REQUIREINPUT);
+    TYPE.setOptions(Opt.STRING, Opt.LINKED, Opt.ALLOWALL);
+    RENDERER.setOptions(Opt.STRING, Opt.LINKED, Opt.ALLOWALL);
     QUIT.setOptions(Opt.UNARY);
-    CLOSE.setOptions(Opt.UNARY, Opt.LINKED);
+    CLOSE.setOptions(Opt.UNARY, Opt.LINKED, Opt.ALLOWALL);
     DEBUG.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);
-    INCREMENT.setOptions(Opt.UNARY, Opt.MULTI, Opt.NOACTION);
+    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(Opt.BOOLEAN, Opt.BOOTSTRAP, Opt.NOACTION);
     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);
-    // Opt.BOOTSTRAP args are parsed (not linked with no SubVals so using a
-    // simplified parser, see jalview.bin.argparser.BootstrapArgs)
-    // before a full parse of arguments and so can be accessible at an earlier
-    // stage to (e.g.) set debug log level, provide a props file (that might set
-    // log level), run headlessly, read an argfile instead of other args.
+    WEBSERVICEDISCOVERY.setOptions(Opt.BOOLEAN, Opt.BOOTSTRAP);
+    ALL.setOptions(Opt.BOOLEAN, Opt.MULTI, Opt.NOACTION);
+
   }
 
   private final String[] argNames;