1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.bin.argparser; |
22 |
|
|
23 |
|
import java.util.ArrayList; |
24 |
|
import java.util.Arrays; |
25 |
|
import java.util.Collections; |
26 |
|
import java.util.Comparator; |
27 |
|
import java.util.EnumSet; |
28 |
|
import java.util.HashSet; |
29 |
|
import java.util.Iterator; |
30 |
|
import java.util.List; |
31 |
|
import java.util.Locale; |
32 |
|
import java.util.Set; |
33 |
|
import java.util.stream.Collectors; |
34 |
|
|
35 |
|
import jalview.bin.argparser.Arg.Opt; |
36 |
|
import jalview.util.ChannelProperties; |
37 |
|
import jalview.util.Platform; |
38 |
|
|
|
|
| 21.7% |
Uncovered Elements: 260 (332) |
Complexity: 95 |
Complexity Density: 0.46 |
|
39 |
|
public enum Arg |
40 |
|
{ |
41 |
|
|
42 |
|
|
43 |
|
HELP(Type.HELP, "h", "Display basic help", Opt.UNARY, Opt.BOOTSTRAP, |
44 |
|
Opt.HASTYPE, Opt.MULTIVALUE), |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
VERSION(Type.CONFIG, "v", |
49 |
|
"Display the version of " |
50 |
|
+ ChannelProperties.getProperty("app_name"), |
51 |
|
Opt.UNARY, Opt.BOOTSTRAP), |
52 |
|
HEADLESS(Type.CONFIG, |
53 |
|
"Run Jalview in headless mode. No GUI interface will be created and Jalview will quit after all arguments have been processed. " |
54 |
|
+ "Headless mode is assumed if an output file is to be generated, this can be overridden with --gui.", |
55 |
|
Opt.UNARY, Opt.BOOTSTRAP), |
56 |
|
GUI(Type.CONFIG, |
57 |
|
"Do not run Jalview in headless mode. This overrides the assumption of headless mode when an output file is to be generated.", |
58 |
|
Opt.UNARY, Opt.BOOTSTRAP), |
59 |
|
JABAWS(Type.CONFIG, "Set a different URL to connect to a JABAWS server.", |
60 |
|
Opt.STRING, Opt.BOOTSTRAP), |
61 |
|
NEWS(Type.CONFIG, "Show (or don't show) the news feed.", true, |
62 |
|
Opt.BOOLEAN, Opt.BOOTSTRAP), |
63 |
|
SPLASH(Type.CONFIG, |
64 |
|
"Show (or don't show) the About Jalview splash screen.", true, |
65 |
|
Opt.BOOLEAN, Opt.BOOTSTRAP), |
66 |
|
QUESTIONNAIRE(Type.CONFIG, |
67 |
|
"Show (or don't show) the questionnaire if one is available.", |
68 |
|
true, Opt.BOOLEAN, Opt.BOOTSTRAP), |
69 |
|
JAVACONSOLE(Type.CONFIG, "Show (or don't show) the Java Console.", false, |
70 |
|
Opt.BOOLEAN, Opt.BOOTSTRAP), |
71 |
|
NOUSAGESTATS(Type.CONFIG, "Don't send initial launch usage stats.", |
72 |
|
Opt.UNARY, Opt.BOOTSTRAP), |
73 |
|
NOSTARTUPFILE(Type.CONFIG, "Don't show the default startup file.", |
74 |
|
Opt.UNARY, Opt.BOOTSTRAP), |
75 |
|
WEBSERVICEDISCOVERY(Type.CONFIG, |
76 |
|
"Attempt (or don't attempt) to connect to JABAWS web services.", |
77 |
|
true, Opt.BOOLEAN, Opt.BOOTSTRAP), |
78 |
|
PROPS(Type.CONFIG, |
79 |
|
"Use a file as the preferences file instead of the usual ~/" |
80 |
|
+ ChannelProperties.getProperty("preferences.filename") |
81 |
|
+ " file.", |
82 |
|
Opt.STRING, Opt.BOOTSTRAP), |
83 |
|
DEBUG(Type.CONFIG, "d", "Start Jalview in debug log level.", Opt.BOOLEAN, |
84 |
|
Opt.BOOTSTRAP), |
85 |
|
TRACE(Type.CONFIG, "Start Jalview in trace log level.", Opt.BOOLEAN, |
86 |
|
Opt.BOOTSTRAP, Opt.SECRET), |
87 |
|
QUIET(Type.CONFIG, "q", |
88 |
|
"Stop all output to STDOUT (after the Java Virtual Machine has started). Use ‑‑quiet a second time to stop all output to STDERR.", |
89 |
|
Opt.UNARY, Opt.MULTIVALUE, Opt.BOOTSTRAP), |
90 |
|
INITSUBSTITUTIONS(Type.CONFIG, |
91 |
|
"Set ‑‑substitutions to be initially enabled (or initially disabled).", |
92 |
|
true, Opt.BOOLEAN, Opt.BOOTSTRAP, Opt.NOACTION, Opt.SECRET), |
93 |
|
P(Type.CONFIG, "Set a Jalview preference value for this session.", |
94 |
|
Opt.PREFIXKEV, Opt.PRESERVECASE, Opt.STRING, Opt.BOOTSTRAP, |
95 |
|
Opt.MULTIVALUE, Opt.NOACTION, Opt.SECRET), |
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
OPEN(Type.OPENING, |
100 |
|
"Opens one or more alignment files or URLs in new alignment windows.", |
101 |
|
Opt.STRING, Opt.LINKED, Opt.INCREMENTDEFAULTCOUNTER, |
102 |
|
Opt.MULTIVALUE, Opt.GLOB, Opt.ALLOWSUBSTITUTIONS, Opt.INPUT, |
103 |
|
Opt.STORED, Opt.PRIMARY), |
104 |
|
APPEND(Type.OPENING, |
105 |
|
"Appends one or more alignment files or URLs to the open alignment window (or opens a new alignment if none already open).", |
106 |
|
Opt.STRING, Opt.LINKED, Opt.MULTIVALUE, Opt.GLOB, |
107 |
|
Opt.ALLOWSUBSTITUTIONS, Opt.INPUT, Opt.PRIMARY), |
108 |
|
TITLE(Type.OPENING, |
109 |
|
"Specifies the title for the open alignment window as string.", |
110 |
|
Opt.STRING, Opt.LINKED, Opt.ALLOWMULTIID), |
111 |
|
COLOUR(Type.OPENING, "color", |
112 |
|
"Applies the colour scheme to the open alignment window. Valid values include:\n" |
113 |
|
+ "clustal,\n" + "blosum62,\n" + "pc-identity,\n" |
114 |
|
+ "zappo,\n" + "taylor,\n" + "gecos-flower,\n" |
115 |
|
+ "gecos-blossom,\n" + "gecos-sunset,\n" |
116 |
|
+ "gecos-ocean,\n" + "hydrophobic,\n" |
117 |
|
+ "helix-propensity,\n" + "strand-propensity,\n" |
118 |
|
+ "turn-propensity,\n" + "buried-index,\n" |
119 |
|
+ "nucleotide,\n" + "nucleotide-ambiguity,\n" |
120 |
|
+ "purine-pyrimidine,\n" + "rna-helices,\n" |
121 |
|
+ "t-coffee-scores,\n" + "sequence-id.\n" + "\n" |
122 |
|
+ "Names of user defined colourschemes will also work,\n" |
123 |
|
+ "and jalview colourscheme specifications like\n" |
124 |
|
+ "--colour=\"D,E=red; K,R,H=0022FF; C,c=yellow\"", |
125 |
|
Opt.STRING, Opt.LINKED, Opt.ALLOWMULTIID), |
126 |
|
FEATURES(Type.OPENING, "Add a feature file or URL to the open alignment.", |
127 |
|
Opt.STRING, Opt.LINKED, Opt.MULTIVALUE, Opt.ALLOWSUBSTITUTIONS, |
128 |
|
Opt.ALLOWMULTIID), |
129 |
|
TREE(Type.OPENING, "Add a tree file or URL to the open alignment.", |
130 |
|
Opt.STRING, Opt.LINKED, Opt.MULTIVALUE, Opt.ALLOWSUBSTITUTIONS, |
131 |
|
Opt.ALLOWMULTIID), |
132 |
|
SORTBYTREE(Type.OPENING, |
133 |
|
"Enforces sorting (or not sorting) the open alignment in the order of an attached phylogenetic tree.", |
134 |
|
true, Opt.LINKED, Opt.BOOLEAN, Opt.ALLOWMULTIID), |
135 |
|
ANNOTATIONS(Type.OPENING, |
136 |
|
"Add an annotations file or URL to the open alignment.", |
137 |
|
Opt.STRING, Opt.LINKED, Opt.MULTIVALUE, Opt.ALLOWSUBSTITUTIONS, |
138 |
|
Opt.ALLOWMULTIID), |
139 |
|
SHOWANNOTATIONS(Type.OPENING, |
140 |
|
"Enforces showing (or not showing) alignment annotations.", |
141 |
|
Opt.BOOLEAN, Opt.LINKED, Opt.ALLOWMULTIID, Opt.ALLOWMULTIID), |
142 |
|
WRAP(Type.OPENING, |
143 |
|
"Enforces wrapped (or not wrapped) alignment formatting.", |
144 |
|
Opt.BOOLEAN, Opt.LINKED, Opt.ALLOWMULTIID, Opt.ALLOWMULTIID), |
145 |
|
NOSTRUCTURE(Type.OPENING, |
146 |
|
"Do not open or process any 3D structure in the ‑‑open or ‑‑append files.", |
147 |
|
Opt.UNARY, Opt.LINKED, Opt.ALLOWMULTIID, Opt.ALLOWMULTIID), |
148 |
|
|
149 |
|
|
150 |
|
STRUCTURE(Type.STRUCTURE, |
151 |
|
"Load a structure file or URL associated with a sequence in the open alignment.\n" |
152 |
|
+ "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.", |
153 |
|
Opt.STRING, Opt.LINKED, Opt.MULTIVALUE, Opt.ALLOWSUBSTITUTIONS, |
154 |
|
Opt.PRIMARY, Opt.ALLOWMULTIID), |
155 |
|
SEQID(Type.STRUCTURE, |
156 |
|
"Specify the sequence name for the preceding --structure to be associated with.", |
157 |
|
Opt.STRING, Opt.LINKED, Opt.MULTIVALUE, Opt.ALLOWSUBSTITUTIONS, |
158 |
|
Opt.ALLOWMULTIID), |
159 |
|
PAEMATRIX(Type.STRUCTURE, |
160 |
|
"Add a PAE json matrix file to the preceding --structure.", |
161 |
|
Opt.STRING, Opt.LINKED, Opt.MULTIVALUE, Opt.ALLOWSUBSTITUTIONS, |
162 |
|
Opt.ALLOWMULTIID), |
163 |
|
TEMPFAC(Type.STRUCTURE, |
164 |
|
"Set the type of temperature factor. Possible values are:\n" |
165 |
|
+ "default,\n" + "plddt.", |
166 |
|
Opt.STRING, Opt.LINKED, Opt.MULTIVALUE, Opt.ALLOWMULTIID), |
167 |
|
STRUCTUREVIEWER(Type.STRUCTURE, |
168 |
|
"Set the structure viewer to use to open the 3D structure file specified in previous --structure to name. Possible values of name are:\n" |
169 |
|
+ "none,\n" + "jmol,\n" + "chimera,\n" + "chimerax,\n" |
170 |
|
+ "pymol.", |
171 |
|
Opt.STRING, Opt.LINKED, Opt.MULTIVALUE, Opt.ALLOWMULTIID), |
172 |
|
NOTEMPFAC(Type.STRUCTURE, |
173 |
|
"Do not show the temperature factor annotation for the preceding --structure.", |
174 |
|
Opt.UNARY, Opt.LINKED, Opt.ALLOWMULTIID, Opt.SECRET), |
175 |
|
|
176 |
|
|
177 |
|
SHOWSSANNOTATIONS(Type.STRUCTURE, null, Opt.BOOLEAN, Opt.LINKED, |
178 |
|
Opt.ALLOWMULTIID), |
179 |
|
|
180 |
|
|
181 |
|
IMAGE(Type.IMAGE, |
182 |
|
"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" |
183 |
|
+ "svg,\n" + "png,\n" + "eps,\n" + "html,\n" + "biojs.", |
184 |
|
Opt.STRING, Opt.LINKED, Opt.ALLOWSUBSTITUTIONS, Opt.MULTIVALUE, |
185 |
|
Opt.ALLOWMULTIID, Opt.REQUIREINPUT, Opt.OUTPUTFILE, Opt.PRIMARY), |
186 |
|
STRUCTUREIMAGE(new Type[] |
187 |
|
{ Type.IMAGE, Type.STRUCTUREIMAGE }, |
188 |
|
"Export an image of a 3D structure opened in JMOL", Opt.STRING, |
189 |
|
Opt.LINKED, Opt.MULTIVALUE, Opt.OUTPUTFILE, Opt.ALLOWMULTIID, |
190 |
|
Opt.PRIMARY), |
191 |
|
TYPE(Type.IMAGE, |
192 |
|
"Set the image format for the preceding " + Arg.IMAGE.argString() |
193 |
|
+ " or " + Arg.STRUCTUREIMAGE.argString() |
194 |
|
+ ". Valid values are:\n" + "svg,\n" + "png,\n" + "eps,\n" |
195 |
|
+ "html,\n" + "biojs.", |
196 |
|
Opt.STRING, Opt.LINKED, Opt.MULTIVALUE, Opt.ALLOWMULTIID), |
197 |
|
TEXTRENDERER(Type.IMAGE, |
198 |
|
"Sets whether text in a vector image format (SVG, HTML, EPS) should be rendered as text or vector line-art. Possible values are:\n" |
199 |
|
+ "text,\n" + "lineart.", |
200 |
|
Opt.STRING, Opt.LINKED, Opt.MULTIVALUE, Opt.ALLOWMULTIID), |
201 |
|
SCALE(Type.IMAGE, |
202 |
|
"Sets a scaling for bitmap image format (PNG). Should be given as a floating point number. If used in conjunction with --width and --height then the smallest scaling will be used (scale, width and height provide bounds for the image).", |
203 |
|
Opt.STRING, Opt.LINKED, Opt.MULTIVALUE, Opt.ALLOWMULTIID), |
204 |
|
WIDTH(Type.IMAGE, |
205 |
|
"Sets a width for bitmap image format (PNG) with the height maintaining the aspect ratio. Should be given as a positive integer. If used in conjunction with --scale and --height then the smallest scaling will be used (scale, width and height provide bounds for the image).", |
206 |
|
Opt.STRING, Opt.LINKED, Opt.MULTIVALUE, Opt.ALLOWMULTIID), |
207 |
|
HEIGHT(Type.IMAGE, |
208 |
|
"Sets a height for bitmap image format (PNG) with the width maintaining the aspect ratio. Should be given as a positive integer. If used in conjunction with --scale and --width then the smallest scaling will be used (scale, width and height provide bounds for the image).", |
209 |
|
Opt.STRING, Opt.LINKED, Opt.MULTIVALUE, Opt.ALLOWMULTIID), |
210 |
|
IMAGECOLOUR(Type.IMAGE, "imagecolor", |
211 |
|
"Applies the colour scheme to the open alignment window for this image, otherwise the value of " |
212 |
|
+ Arg.COLOUR.argString() |
213 |
|
+ " (or none) will apply. Valid values are the same as " |
214 |
|
+ Arg.COLOUR.argString() + ".", |
215 |
|
Opt.STRING, Opt.LINKED, Opt.MULTIVALUE, Opt.ALLOWMULTIID), |
216 |
|
BGCOLOUR(Type.IMAGE, "bgcolor", |
217 |
|
"Applies a background colour to the structure image. Valid values are named colours known to Java or RRGGBB 6 digit hex-string.", |
218 |
|
Opt.STRING, Opt.LINKED, Opt.MULTIVALUE, Opt.ALLOWMULTIID), |
219 |
|
OUTPUT(Type.OUTPUT, |
220 |
|
"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" |
221 |
|
+ "fasta (fa, fasta, mfa, fastq),\n" + "pfam (pfam),\n" |
222 |
|
+ "stockholm (sto, stk),\n" + "pir (pir),\n" |
223 |
|
+ "blc (blc),\n" + "amsa (amsa),\n" + "json (json),\n" |
224 |
|
+ "pileup (pileup),\n" + "msf (msf),\n" |
225 |
|
+ "clustal (aln),\n" + "phylip (phy),\n" |
226 |
|
+ "jalview (jvp, jar).", |
227 |
|
Opt.STRING, Opt.LINKED, Opt.ALLOWSUBSTITUTIONS, Opt.ALLOWMULTIID, |
228 |
|
Opt.REQUIREINPUT, Opt.OUTPUTFILE, Opt.STDOUT, Opt.PRIMARY), |
229 |
|
FORMAT(Type.OUTPUT, |
230 |
|
"Sets the format for the preceding --output file. Valid formats are:\n" |
231 |
|
+ "fasta,\n" + "pfam,\n" + "stockholm,\n" + "pir,\n" |
232 |
|
+ "blc,\n" + "amsa,\n" + "json,\n" + "pileup,\n" |
233 |
|
+ "msf,\n" + "clustal,\n" + "phylip,\n" + "jalview.", |
234 |
|
Opt.STRING, Opt.LINKED, Opt.ALLOWMULTIID), |
235 |
|
GROOVY(Type.PROCESS, |
236 |
|
"Process a groovy script in the file for the open alignment.", |
237 |
|
Opt.STRING, Opt.LINKED, Opt.MULTIVALUE, Opt.ALLOWSUBSTITUTIONS, |
238 |
|
Opt.ALLOWMULTIID), |
239 |
|
BACKUPS(Type.OUTPUT, |
240 |
|
"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.", |
241 |
|
true, Opt.BOOLEAN, Opt.LINKED, Opt.ALLOWMULTIID), |
242 |
|
OVERWRITE(Type.OUTPUT, |
243 |
|
"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.", |
244 |
|
Opt.BOOLEAN, Opt.LINKED, Opt.ALLOWMULTIID), |
245 |
|
CLOSE(Type.OPENING, |
246 |
|
"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.", |
247 |
|
Opt.UNARY, Opt.LINKED, Opt.ALLOWMULTIID), |
248 |
|
MKDIRS(Type.OUTPUT, |
249 |
|
"Automatically create directories when outputting a file to a new directory.", |
250 |
|
Opt.UNARY, Opt.LINKED, Opt.ALLOWMULTIID), |
251 |
|
|
252 |
|
|
253 |
|
NEW(Type.FLOW, |
254 |
|
"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.", |
255 |
|
Opt.UNARY, Opt.MULTIVALUE, Opt.NOACTION, |
256 |
|
Opt.INCREMENTDEFAULTCOUNTER), |
257 |
|
SUBSTITUTIONS(Type.FLOW, |
258 |
|
"The following argument values allow (or don't allow) subsituting filename parts. This is initially true. Valid substitutions are:\n" |
259 |
|
+ "{basename} - the filename-without-extension of the currently --opened file (or first --appended file),\n" |
260 |
|
+ "{dirname} - the directory (folder) name of the currently --opened file (or first --appended file),\n" |
261 |
|
+ "{argfilebasename} - the filename-without-extension of the current --argfile,\n" |
262 |
|
+ "{argfiledirname} - the directory (folder) name of the current --argfile,\n" |
263 |
|
+ "{n} - the value of the index counter (starting at 0).\n" |
264 |
|
+ "{++n} - increase and substitute the value of the index counter,\n" |
265 |
|
+ "{} - the value of the current alignment window default index.", |
266 |
|
true, Opt.BOOLEAN, Opt.MULTIVALUE, Opt.NOACTION), |
267 |
|
ARGFILE(Type.FLOW, |
268 |
|
"Open one or more files filename and read, line-by-line, as arguments to Jalview.\n" |
269 |
|
+ "Values in an argfile should be given with an equals sign (\"=\") separator with no spaces.\n" |
270 |
|
+ "Note that if you use one or more --argfile arguments then all other non-initialising arguments will be ignored.", |
271 |
|
Opt.STRING, Opt.MULTIVALUE, Opt.BOOTSTRAP, Opt.GLOB, |
272 |
|
Opt.ALLOWSUBSTITUTIONS), |
273 |
|
NPP(Type.FLOW, "n++", |
274 |
|
"Increase the index counter used in argument value substitutions.", |
275 |
|
Opt.UNARY, Opt.MULTIVALUE, Opt.NOACTION), |
276 |
|
ALL(Type.FLOW, |
277 |
|
"Apply the following output arguments to all sets of linked arguments.", |
278 |
|
Opt.BOOLEAN, Opt.MULTIVALUE, Opt.NOACTION), |
279 |
|
OPENED(Type.FLOW, |
280 |
|
"Apply the following output arguments to all of the last --open'ed set of linked arguments.", |
281 |
|
Opt.BOOLEAN, Opt.MULTIVALUE, Opt.NOACTION), |
282 |
|
QUIT(Type.FLOW, |
283 |
|
"After all files have been opened, appended and output, quit Jalview. In ‑‑headless mode this already happens.", |
284 |
|
Opt.UNARY), |
285 |
|
NOQUIT(Type.FLOW, |
286 |
|
"Secret arg to not quit after --headless mode for tests", |
287 |
|
Opt.UNARY, Opt.SECRET), |
288 |
|
ALLSTRUCTURES(Type.FLOW, |
289 |
|
"Apply the following 3D structure formatting arguments to all structures within the open alignment.", |
290 |
|
Opt.BOOLEAN, Opt.MULTIVALUE, Opt.NOACTION), |
291 |
|
|
292 |
|
|
293 |
|
TESTOUTPUT(Type.CONFIG, |
294 |
|
"Allow specific stdout information. For testing purposes only.", |
295 |
|
Opt.UNARY, Opt.BOOTSTRAP, Opt.SECRET), |
296 |
|
SETPROP(Type.CONFIG, "Set an individual Java System property.", |
297 |
|
Opt.STRING, Opt.MULTIVALUE, Opt.BOOTSTRAP, Opt.SECRET), |
298 |
|
|
299 |
|
NIL(Type.FLOW, |
300 |
|
"This argument does nothing on its own, but can be used with linkedIds.", |
301 |
|
Opt.UNARY, Opt.LINKED, Opt.MULTIVALUE, Opt.NOACTION, Opt.SECRET), |
302 |
|
|
303 |
|
|
304 |
|
SETARGFILE(Type.FLOW, |
305 |
|
"Sets the current value of the argfilename. Inserted before argfilecontents.", |
306 |
|
Opt.UNARY, Opt.LINKED, Opt.STRING, Opt.MULTIVALUE, Opt.PRIVATE, |
307 |
|
Opt.NOACTION), |
308 |
|
UNSETARGFILE(Type.FLOW, |
309 |
|
"Unsets the current value of the argfilename. Inserted after argfile contents.", |
310 |
|
Opt.UNARY, Opt.LINKED, Opt.MULTIVALUE, Opt.PRIVATE, Opt.NOACTION), |
311 |
|
|
312 |
|
|
313 |
|
|
314 |
|
|
315 |
|
JVMMEMPC(Type.CONFIG, |
316 |
|
"Limit maximum heap size (memory) to PERCENT% of total physical memory detected. This defaults to 90 if total physical memory can be detected.\n" |
317 |
|
+ "The equals sign (\"=\") separator must be used with no spaces.", |
318 |
|
Opt.NOACTION, Opt.BOOTSTRAP, Opt.STRING, Opt.LAST), |
319 |
|
JVMMEMMAX(Type.CONFIG, |
320 |
|
"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" |
321 |
|
+ "The equals sign (\"=\") separator must be used with no spaces.", |
322 |
|
Opt.NOACTION, Opt.BOOTSTRAP, Opt.STRING, Opt.LAST), |
323 |
|
|
324 |
|
; |
325 |
|
|
|
|
| 33.3% |
Uncovered Elements: 4 (6) |
Complexity: 3 |
Complexity Density: 1 |
|
326 |
|
public static enum Opt |
327 |
|
{ |
328 |
|
|
329 |
|
|
330 |
|
|
331 |
|
|
332 |
|
|
333 |
|
BOOLEAN("can be negated with " + ArgParser.DOUBLEDASH |
334 |
|
+ ArgParser.NEGATESTRING + "..."), |
335 |
|
|
336 |
|
|
337 |
|
|
338 |
|
|
339 |
|
STRING("expects a value"), |
340 |
|
|
341 |
|
|
342 |
|
|
343 |
|
|
344 |
|
UNARY(null), |
345 |
|
|
346 |
|
|
347 |
|
|
348 |
|
|
349 |
|
MULTIVALUE("can be specified multiple times"), |
350 |
|
|
351 |
|
|
352 |
|
|
353 |
|
|
354 |
|
LINKED("is linked to an alignment"), |
355 |
|
|
356 |
|
|
357 |
|
|
358 |
|
|
359 |
|
NODUPLICATEVALUES("cannot have the same value more than once"), |
360 |
|
|
361 |
|
|
362 |
|
|
363 |
|
|
364 |
|
|
365 |
|
BOOTSTRAP("a configuration argument"), |
366 |
|
|
367 |
|
|
368 |
|
|
369 |
|
|
370 |
|
|
371 |
|
|
372 |
|
|
373 |
|
GLOB("can take multiple filenames with wildcards"), |
374 |
|
|
375 |
|
|
376 |
|
|
377 |
|
|
378 |
|
NOACTION(null), |
379 |
|
|
380 |
|
|
381 |
|
|
382 |
|
|
383 |
|
ALLOWSUBSTITUTIONS("values can use substitutions"), |
384 |
|
|
385 |
|
|
386 |
|
|
387 |
|
PRIVATE(null), |
388 |
|
|
389 |
|
|
390 |
|
|
391 |
|
|
392 |
|
SECRET(null), |
393 |
|
|
394 |
|
|
395 |
|
|
396 |
|
ALLOWMULTIID("can be used with " + ArgParser.DOUBLEDASH + "all"), |
397 |
|
|
398 |
|
|
399 |
|
|
400 |
|
|
401 |
|
INCREMENTDEFAULTCOUNTER("starts a new default alignment"), |
402 |
|
|
403 |
|
|
404 |
|
|
405 |
|
INPUT(null), |
406 |
|
|
407 |
|
|
408 |
|
|
409 |
|
|
410 |
|
REQUIREINPUT(null), |
411 |
|
|
412 |
|
|
413 |
|
|
414 |
|
|
415 |
|
OUTPUTFILE("output file --headless will be assumed unless --gui used"), |
416 |
|
|
417 |
|
|
418 |
|
|
419 |
|
STDOUT("allows the output filename '" + ArgParser.STDOUTFILENAME |
420 |
|
+ "' to mean output to STDOUT"), |
421 |
|
|
422 |
|
|
423 |
|
|
424 |
|
STORED(null), |
425 |
|
|
426 |
|
|
427 |
|
|
428 |
|
HELP("provides a help statement"), |
429 |
|
|
430 |
|
|
431 |
|
|
432 |
|
PRIMARY("is a primary argument for its type"), |
433 |
|
|
434 |
|
|
435 |
|
|
436 |
|
HASTYPE(null), |
437 |
|
|
438 |
|
|
439 |
|
|
440 |
|
FIRST(null), |
441 |
|
|
442 |
|
|
443 |
|
|
444 |
|
LAST(null), |
445 |
|
|
446 |
|
|
447 |
|
|
448 |
|
PREFIXKEV("prefixes key=value"), |
449 |
|
|
450 |
|
|
451 |
|
|
452 |
|
PRESERVECASE(null), |
453 |
|
|
454 |
|
; |
455 |
|
|
456 |
|
private String description; |
457 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
458 |
0 |
private Opt()... |
459 |
|
{ |
460 |
0 |
description = null; |
461 |
|
} |
462 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
463 |
1404 |
private Opt(String description)... |
464 |
|
{ |
465 |
1404 |
this.description = description; |
466 |
|
} |
467 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
468 |
0 |
public String description()... |
469 |
|
{ |
470 |
0 |
return description; |
471 |
|
} |
472 |
|
|
473 |
|
} |
474 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 3 |
Complexity Density: 1 |
|
475 |
|
public static enum Type |
476 |
|
{ |
477 |
|
|
478 |
|
HELP, |
479 |
|
CONFIG("arguments used to configure " |
480 |
|
+ ChannelProperties.getProperty("app_name") + " from startup"), |
481 |
|
OPENING("arguments used to open and format alignments"), |
482 |
|
STRUCTURE("arguments used to add and format 3D structure data"), |
483 |
|
PROCESS("arguments used to process an alignment once opened"), |
484 |
|
OUTPUT("arguments used to save data from a processed alignment"), |
485 |
|
IMAGE("arguments used to export an image of an alignment"), |
486 |
|
STRUCTUREIMAGE("arguments used to export an image of an structure"), |
487 |
|
FLOW("arguments that control processing of the other arguments"), |
488 |
|
ALL("all arguments"), |
489 |
|
NONE, |
490 |
|
INVALID; |
491 |
|
|
492 |
|
private String description; |
493 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
494 |
162 |
private Type()... |
495 |
|
{ |
496 |
162 |
description = null; |
497 |
|
} |
498 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
499 |
486 |
private Type(String description)... |
500 |
|
{ |
501 |
486 |
this.description = description; |
502 |
|
} |
503 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
504 |
0 |
public String description()... |
505 |
|
{ |
506 |
0 |
return description; |
507 |
|
} |
508 |
|
} |
509 |
|
|
510 |
|
private final String[] argNames; |
511 |
|
|
512 |
|
private Opt[] argOptions; |
513 |
|
|
514 |
|
private boolean defaultBoolValue; |
515 |
|
|
516 |
|
private String description; |
517 |
|
|
518 |
|
private Type[] types; |
519 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
520 |
2700 |
private Arg(Type type, String description, Opt... options)... |
521 |
|
{ |
522 |
2700 |
this(new Type[] { type }, description, options); |
523 |
|
} |
524 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
525 |
2754 |
private Arg(Type[] type, String description, Opt... options)... |
526 |
|
{ |
527 |
2754 |
this(type, null, description, false, options); |
528 |
|
} |
529 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
530 |
486 |
private Arg(Type type, String description, boolean defaultBoolean,... |
531 |
|
Opt... options) |
532 |
|
{ |
533 |
486 |
this(new Type[] { type }, description, defaultBoolean, options); |
534 |
|
} |
535 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
536 |
486 |
private Arg(Type[] type, String description, boolean defaultBoolean,... |
537 |
|
Opt... options) |
538 |
|
{ |
539 |
486 |
this(type, null, description, defaultBoolean, options); |
540 |
|
} |
541 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
542 |
432 |
private Arg(Type type, String alternativeName, String description,... |
543 |
|
Opt... options) |
544 |
|
{ |
545 |
432 |
this(new Type[] { type }, alternativeName, description, options); |
546 |
|
} |
547 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
548 |
432 |
private Arg(Type[] type, String alternativeName, String description,... |
549 |
|
Opt... options) |
550 |
|
{ |
551 |
432 |
this(type, alternativeName, description, false, options); |
552 |
|
} |
553 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
554 |
0 |
private Arg(Type type, String alternativeName, String description,... |
555 |
|
boolean defaultBoolean, Opt... options) |
556 |
|
{ |
557 |
0 |
this(new Type[] { type }, alternativeName, description, defaultBoolean, |
558 |
|
options); |
559 |
|
} |
560 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
561 |
3672 |
private Arg(Type[] type, String alternativeName, String description,... |
562 |
|
boolean defaultBoolean, Opt... options) |
563 |
|
{ |
564 |
3672 |
this.types = type; |
565 |
3672 |
this.description = description; |
566 |
3672 |
this.defaultBoolValue = defaultBoolean; |
567 |
3672 |
this.setOptions(options); |
568 |
3672 |
this.argNames = alternativeName != null |
569 |
|
? new String[] |
570 |
|
{ this.getName(), alternativeName } |
571 |
|
: new String[] |
572 |
|
{ this.getName() }; |
573 |
|
} |
574 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
575 |
604 |
public String argString()... |
576 |
|
{ |
577 |
604 |
return argString(false); |
578 |
|
} |
579 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
580 |
1 |
public String negateArgString()... |
581 |
|
{ |
582 |
1 |
return argString(true); |
583 |
|
} |
584 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
585 |
605 |
private String argString(boolean negate)... |
586 |
|
{ |
587 |
605 |
StringBuilder sb = new StringBuilder(ArgParser.DOUBLEDASH); |
588 |
605 |
if (negate && hasOption(Opt.BOOLEAN)) |
589 |
1 |
sb.append(ArgParser.NEGATESTRING); |
590 |
605 |
sb.append(getName()); |
591 |
605 |
return sb.toString(); |
592 |
|
} |
593 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 3 |
Complexity Density: 0.18 |
|
594 |
0 |
public String toLongString()... |
595 |
|
{ |
596 |
0 |
StringBuilder sb = new StringBuilder(); |
597 |
0 |
sb.append(this.getClass().getName()).append('.').append(this.name()); |
598 |
0 |
sb.append('('); |
599 |
0 |
if (getNames().length > 0) |
600 |
0 |
sb.append('"'); |
601 |
0 |
sb.append(String.join("\", \"", getNames())); |
602 |
0 |
if (getNames().length > 0) |
603 |
0 |
sb.append('"'); |
604 |
0 |
sb.append(")\n"); |
605 |
0 |
for (Type type : getTypes()) |
606 |
|
{ |
607 |
0 |
String typeName = type.name(); |
608 |
0 |
sb.append("\nType: " + typeName); |
609 |
|
} |
610 |
0 |
sb.append("\nOpt: "); |
611 |
|
|
612 |
0 |
List<String> optList = Arrays.asList(argOptions).stream() |
613 |
|
.map(opt -> opt.name()).collect(Collectors.toList()); |
614 |
0 |
sb.append(String.join(", ", optList)); |
615 |
0 |
sb.append("\n"); |
616 |
0 |
return sb.toString(); |
617 |
|
} |
618 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
619 |
3672 |
public String[] getNames()... |
620 |
|
{ |
621 |
3672 |
return argNames; |
622 |
|
} |
623 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
624 |
7638 |
public String getName()... |
625 |
|
{ |
626 |
7638 |
String name = hasOption(Opt.PRESERVECASE) ? this.name() |
627 |
|
: this.name().toLowerCase(Locale.ROOT); |
628 |
7638 |
return name.replace('_', '-'); |
629 |
|
} |
630 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
631 |
839 |
@Override... |
632 |
|
public final String toString() |
633 |
|
{ |
634 |
839 |
return getName(); |
635 |
|
} |
636 |
|
|
|
|
| 80% |
Uncovered Elements: 2 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
637 |
40175 |
public boolean hasOption(Opt o)... |
638 |
|
{ |
639 |
40175 |
if (argOptions == null) |
640 |
0 |
return false; |
641 |
40175 |
for (Opt option : argOptions) |
642 |
|
{ |
643 |
153712 |
if (o == option) |
644 |
10152 |
return true; |
645 |
|
} |
646 |
30023 |
return false; |
647 |
|
} |
648 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
649 |
0 |
public boolean hasAllOptions(Opt... opts)... |
650 |
|
{ |
651 |
0 |
for (Opt o : opts) |
652 |
|
{ |
653 |
0 |
if (!this.hasOption(o)) |
654 |
0 |
return false; |
655 |
|
} |
656 |
0 |
return true; |
657 |
|
} |
658 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
659 |
880 |
protected Opt[] getOptions()... |
660 |
|
{ |
661 |
880 |
return argOptions; |
662 |
|
} |
663 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
664 |
3672 |
protected void setOptions(Opt... options)... |
665 |
|
{ |
666 |
3672 |
this.argOptions = options; |
667 |
|
} |
668 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
669 |
1782 |
protected boolean getDefaultBoolValue()... |
670 |
|
{ |
671 |
1782 |
return defaultBoolValue; |
672 |
|
} |
673 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
674 |
6 |
public Type getFirstType()... |
675 |
|
{ |
676 |
6 |
return this.getTypes()[0]; |
677 |
|
} |
678 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
679 |
5046 |
public Type[] getTypes()... |
680 |
|
{ |
681 |
5046 |
return this.types; |
682 |
|
} |
683 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
684 |
2011 |
public boolean sharesType(Arg a)... |
685 |
|
{ |
686 |
2011 |
return this.hasType(a.getTypes()); |
687 |
|
} |
688 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
689 |
2044 |
public boolean hasType(Type... types)... |
690 |
|
{ |
691 |
2044 |
Set<Type> typesSet = new HashSet<>(Arrays.asList(types)); |
692 |
2044 |
return this.hasType(typesSet); |
693 |
|
} |
694 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
695 |
2134 |
public boolean hasType(Set<Type> typesSet)... |
696 |
|
{ |
697 |
2134 |
for (Type type : getTypes()) |
698 |
|
{ |
699 |
2183 |
if (typesSet.contains(type)) |
700 |
|
{ |
701 |
1096 |
return true; |
702 |
|
} |
703 |
|
} |
704 |
1038 |
return false; |
705 |
|
} |
706 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
707 |
0 |
protected String getDescription()... |
708 |
|
{ |
709 |
0 |
return description; |
710 |
|
} |
711 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
712 |
0 |
public static String booleanArgString(Arg a)... |
713 |
|
{ |
714 |
0 |
StringBuilder sb = new StringBuilder(a.argString()); |
715 |
0 |
if (a.hasOption(Opt.BOOLEAN)) |
716 |
|
{ |
717 |
0 |
sb.append('/'); |
718 |
0 |
sb.append(a.negateArgString()); |
719 |
|
} |
720 |
0 |
return sb.toString(); |
721 |
|
} |
722 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
723 |
0 |
public static final String usage()... |
724 |
|
{ |
725 |
0 |
return usage(null); |
726 |
|
} |
727 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 4 |
Complexity Density: 0.4 |
|
728 |
0 |
public static final void appendUsageGeneral(StringBuilder sb,... |
729 |
|
int maxArgLength) |
730 |
|
{ |
731 |
0 |
Set<Type> firstTypes = new HashSet<>(); |
732 |
0 |
for (Arg a : EnumSet.allOf(Arg.class)) |
733 |
|
{ |
734 |
0 |
if (!firstTypes.contains(a.getFirstType())) |
735 |
|
{ |
736 |
0 |
firstTypes.add(a.getFirstType()); |
737 |
|
} |
738 |
|
} |
739 |
0 |
for (Type t : EnumSet.allOf(Type.class)) |
740 |
|
{ |
741 |
0 |
if (t.description() != null && firstTypes.contains(t)) |
742 |
|
{ |
743 |
0 |
StringBuilder argSb = new StringBuilder(); |
744 |
0 |
argSb.append(Arg.HELP.argString()).append(ArgParser.SINGLEDASH) |
745 |
|
.append(t.name().toLowerCase(Locale.ROOT)); |
746 |
0 |
appendArgAndDescription(sb, argSb.toString(), |
747 |
|
"Help for " + t.description(), null, maxArgLength); |
748 |
0 |
sb.append(System.lineSeparator()); |
749 |
|
} |
750 |
|
} |
751 |
|
} |
752 |
|
|
|
|
| 0% |
Uncovered Elements: 46 (46) |
Complexity: 13 |
Complexity Density: 0.41 |
|
753 |
0 |
public static final String usage(List<Type> types)... |
754 |
|
{ |
755 |
0 |
StringBuilder sb = new StringBuilder(); |
756 |
|
|
757 |
0 |
sb.append("usage: jalview [" + Arg.HEADLESS.argString() + "] [[" |
758 |
|
+ Arg.OPEN.argString() + "/" + Arg.APPEND.argString() |
759 |
|
+ "] file(s)] [args]"); |
760 |
0 |
sb.append(System.lineSeparator()); |
761 |
0 |
sb.append(System.lineSeparator()); |
762 |
|
|
763 |
0 |
if (types == null || types.contains(null)) |
764 |
|
{ |
765 |
|
|
766 |
0 |
appendArgAndDescription(sb, null, "Display this basic help", Arg.HELP, |
767 |
|
DESCRIPTIONINDENT); |
768 |
0 |
sb.append(System.lineSeparator()); |
769 |
|
|
770 |
0 |
appendUsageGeneral(sb, DESCRIPTIONINDENT); |
771 |
|
} |
772 |
|
else |
773 |
|
{ |
774 |
0 |
List<Arg> args = argsSortedForDisplay(types); |
775 |
|
|
776 |
0 |
int maxArgLength = DESCRIPTIONINDENT; |
777 |
|
|
778 |
|
|
779 |
0 |
appendArgAndDescription(sb, null, null, Arg.HELP, maxArgLength); |
780 |
0 |
sb.append(System.lineSeparator()); |
781 |
|
|
782 |
0 |
if ((args.contains(Arg.HELP) && types.contains(Type.ALL))) |
783 |
|
{ |
784 |
0 |
appendUsageGeneral(sb, maxArgLength); |
785 |
|
} |
786 |
|
|
787 |
0 |
Iterator<Arg> argsI = args.iterator(); |
788 |
0 |
Type typeSection = null; |
789 |
0 |
while (argsI.hasNext()) |
790 |
|
{ |
791 |
0 |
Arg a = argsI.next(); |
792 |
|
|
793 |
0 |
if (a.hasOption(Opt.PRIVATE) || a.hasOption(Opt.SECRET) |
794 |
|
|| a == Arg.HELP) |
795 |
|
{ |
796 |
0 |
continue; |
797 |
|
} |
798 |
|
|
799 |
0 |
if (a.getFirstType() != typeSection) |
800 |
|
{ |
801 |
0 |
typeSection = a.getFirstType(); |
802 |
0 |
String typeDescription = a.getFirstType().description(); |
803 |
0 |
if (typeDescription != null && typeDescription.length() > 0) |
804 |
|
{ |
805 |
|
|
806 |
|
|
807 |
0 |
typeDescription = typeDescription.toUpperCase(Locale.ROOT); |
808 |
0 |
sb.append(typeDescription); |
809 |
0 |
sb.append(System.lineSeparator()); |
810 |
0 |
sb.append(System.lineSeparator()); |
811 |
|
} |
812 |
|
} |
813 |
|
|
814 |
0 |
appendArgUsage(sb, a, maxArgLength, Platform.consoleWidth()); |
815 |
|
|
816 |
0 |
if (argsI.hasNext()) |
817 |
|
{ |
818 |
0 |
sb.append(System.lineSeparator()); |
819 |
|
} |
820 |
|
} |
821 |
|
} |
822 |
0 |
return sb.toString(); |
823 |
|
} |
824 |
|
|
|
|
| 0% |
Uncovered Elements: 54 (54) |
Complexity: 11 |
Complexity Density: 0.31 |
|
825 |
0 |
private static void appendArgUsage(StringBuilder sb, Arg a,... |
826 |
|
int maxArgLength, int maxWidth) |
827 |
|
{ |
828 |
0 |
boolean first = appendArgAndDescription(sb, null, null, a, |
829 |
|
maxArgLength); |
830 |
0 |
List<String> options = new ArrayList<>(); |
831 |
|
|
832 |
0 |
for (Opt o : EnumSet.allOf(Opt.class)) |
833 |
|
{ |
834 |
0 |
if (a.hasOption(o) && o.description() != null) |
835 |
|
{ |
836 |
0 |
options.add(o.description()); |
837 |
|
} |
838 |
|
} |
839 |
|
|
840 |
0 |
final String optDisplaySeparator = "; "; |
841 |
0 |
if (options.size() > 0) |
842 |
|
{ |
843 |
0 |
int linelength = 0; |
844 |
0 |
String spacing = String.format("%-" |
845 |
|
+ (maxArgLength + ARGDESCRIPTIONSEPARATOR.length()) + "s", |
846 |
|
""); |
847 |
0 |
if (first) |
848 |
|
{ |
849 |
0 |
sb.append(ARGDESCRIPTIONSEPARATOR); |
850 |
0 |
linelength += maxArgLength + ARGDESCRIPTIONSEPARATOR.length(); |
851 |
|
} |
852 |
|
else |
853 |
|
{ |
854 |
0 |
sb.append(spacing); |
855 |
0 |
linelength += spacing.length(); |
856 |
|
} |
857 |
0 |
if (options.size() > 0) |
858 |
|
{ |
859 |
0 |
boolean optFirst = true; |
860 |
0 |
Iterator<String> optionsI = options.listIterator(); |
861 |
0 |
while (optionsI.hasNext()) |
862 |
|
{ |
863 |
0 |
String desc = optionsI.next(); |
864 |
0 |
if (optFirst) |
865 |
|
{ |
866 |
0 |
sb.append("("); |
867 |
0 |
linelength += 1; |
868 |
|
} |
869 |
0 |
int descLength = desc.length() |
870 |
0 |
+ (optionsI.hasNext() ? optDisplaySeparator.length() : 0); |
871 |
0 |
if (linelength + descLength > maxWidth) |
872 |
|
{ |
873 |
0 |
sb.append(System.lineSeparator()); |
874 |
0 |
linelength = 0; |
875 |
0 |
sb.append(spacing); |
876 |
0 |
linelength += spacing.length(); |
877 |
|
} |
878 |
|
|
879 |
0 |
sb.append(desc); |
880 |
0 |
linelength += desc.length(); |
881 |
0 |
if (optionsI.hasNext()) |
882 |
|
{ |
883 |
0 |
sb.append(optDisplaySeparator); |
884 |
0 |
linelength += optDisplaySeparator.length(); |
885 |
|
} |
886 |
0 |
optFirst = false; |
887 |
|
} |
888 |
0 |
sb.append(')'); |
889 |
0 |
sb.append(System.lineSeparator()); |
890 |
|
} |
891 |
|
} |
892 |
|
} |
893 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
894 |
0 |
public static String argDisplayString(Arg a)... |
895 |
|
{ |
896 |
0 |
StringBuilder argSb = new StringBuilder(); |
897 |
0 |
argSb.append( |
898 |
0 |
a.hasOption(Opt.BOOLEAN) ? booleanArgString(a) : a.argString()); |
899 |
0 |
if (a.hasOption(Opt.STRING)) |
900 |
|
{ |
901 |
0 |
if (a.hasOption(Opt.PREFIXKEV)) |
902 |
|
{ |
903 |
0 |
argSb.append("key=value"); |
904 |
|
} |
905 |
|
else |
906 |
|
{ |
907 |
0 |
argSb.append("=value"); |
908 |
|
} |
909 |
|
} |
910 |
0 |
return argSb.toString(); |
911 |
|
} |
912 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
913 |
0 |
public static boolean appendArgAndDescription(StringBuilder sb,... |
914 |
|
String aString, String description, Arg a, int maxArgLength) |
915 |
|
{ |
916 |
0 |
return appendArgAndDescription(sb, aString, description, a, |
917 |
|
maxArgLength, Platform.consoleWidth()); |
918 |
|
} |
919 |
|
|
|
|
| 0% |
Uncovered Elements: 49 (49) |
Complexity: 13 |
Complexity Density: 0.42 |
|
920 |
0 |
public static boolean appendArgAndDescription(StringBuilder sb,... |
921 |
|
String aString, String description, Arg a, int maxArgLength, |
922 |
|
int maxLength) |
923 |
|
{ |
924 |
0 |
if (aString == null && a != null) |
925 |
|
{ |
926 |
0 |
aString = argDisplayString(a); |
927 |
|
} |
928 |
0 |
if (description == null && a != null) |
929 |
|
{ |
930 |
0 |
description = a.getDescription(); |
931 |
|
} |
932 |
0 |
sb.append(String.format("%-" + maxArgLength + "s", aString)); |
933 |
0 |
if (aString.length() > maxArgLength) |
934 |
|
{ |
935 |
0 |
sb.append(System.lineSeparator()); |
936 |
0 |
sb.append(String.format("%-" + maxArgLength + "s", "")); |
937 |
|
} |
938 |
|
|
939 |
0 |
int descLength = maxLength - maxArgLength |
940 |
|
- ARGDESCRIPTIONSEPARATOR.length(); |
941 |
|
|
942 |
0 |
Iterator<String> descLines = null; |
943 |
0 |
if (description != null) |
944 |
|
{ |
945 |
0 |
descLines = Arrays.stream(description.split("\\n")).iterator(); |
946 |
|
} |
947 |
0 |
List<String> splitDescLinesList = new ArrayList<>(); |
948 |
0 |
while (descLines != null && descLines.hasNext()) |
949 |
|
{ |
950 |
0 |
String line = descLines.next(); |
951 |
0 |
while (line.length() > descLength) |
952 |
|
{ |
953 |
0 |
int splitIndex = line.lastIndexOf(" ", descLength); |
954 |
0 |
splitDescLinesList.add(line.substring(0, splitIndex)); |
955 |
0 |
line = line.substring(splitIndex + 1); |
956 |
|
} |
957 |
0 |
splitDescLinesList.add(line); |
958 |
|
} |
959 |
|
|
960 |
0 |
Iterator<String> splitDescLines = splitDescLinesList.iterator(); |
961 |
0 |
boolean first = true; |
962 |
0 |
if (splitDescLines != null) |
963 |
|
{ |
964 |
0 |
while (splitDescLines.hasNext()) |
965 |
|
{ |
966 |
0 |
if (first) |
967 |
|
{ |
968 |
0 |
sb.append(ARGDESCRIPTIONSEPARATOR); |
969 |
|
} |
970 |
|
else |
971 |
|
{ |
972 |
0 |
sb.append(String.format("%-" |
973 |
|
+ (maxArgLength + ARGDESCRIPTIONSEPARATOR.length()) + "s", |
974 |
|
"")); |
975 |
|
} |
976 |
0 |
sb.append(splitDescLines.next()); |
977 |
0 |
sb.append(System.lineSeparator()); |
978 |
0 |
first = false; |
979 |
|
} |
980 |
|
} |
981 |
0 |
return first; |
982 |
|
} |
983 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
984 |
0 |
protected static Iterator<Arg> getAllOfType(Type type)... |
985 |
|
{ |
986 |
0 |
return getAllOfType(type, new Opt[] {}); |
987 |
|
} |
988 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 4 |
Complexity Density: 0.5 |
|
989 |
0 |
protected static Iterator<Arg> getAllOfType(Type type, Opt... options)... |
990 |
|
{ |
991 |
0 |
Opt[] opts = options == null ? new Opt[] {} : options; |
992 |
0 |
return EnumSet.allOf(Arg.class).stream().filter(a -> { |
993 |
0 |
if (!a.hasType(type)) |
994 |
0 |
return false; |
995 |
0 |
for (Opt o : opts) |
996 |
|
{ |
997 |
0 |
if (!a.hasOption(o)) |
998 |
0 |
return false; |
999 |
|
} |
1000 |
0 |
return true; |
1001 |
|
}).iterator(); |
1002 |
|
} |
1003 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 5 |
Complexity Density: 0.5 |
|
1004 |
0 |
private static List<Arg> argsSortedForDisplay(List<Type> types)... |
1005 |
|
{ |
1006 |
0 |
List<Arg> argsToSort; |
1007 |
|
|
1008 |
0 |
if (types == null || types.size() == 0 || types.contains(Type.ALL)) |
1009 |
|
{ |
1010 |
0 |
argsToSort = Arrays |
1011 |
|
.asList(EnumSet.allOf(Arg.class).toArray(new Arg[] {})); |
1012 |
|
} |
1013 |
|
else |
1014 |
|
{ |
1015 |
0 |
argsToSort = new ArrayList<>(); |
1016 |
0 |
for (Type type : types) |
1017 |
|
{ |
1018 |
0 |
if (type == null) |
1019 |
0 |
continue; |
1020 |
0 |
Arg.getAllOfType(type).forEachRemaining(a -> argsToSort.add(a)); |
1021 |
|
} |
1022 |
|
} |
1023 |
|
|
1024 |
0 |
Collections.sort(argsToSort, new ArgDisplayComparator()); |
1025 |
0 |
return argsToSort; |
1026 |
|
} |
1027 |
|
|
1028 |
|
private static final String ARGDESCRIPTIONSEPARATOR = " - "; |
1029 |
|
|
1030 |
|
private static final int DESCRIPTIONINDENT = 20; |
1031 |
|
|
1032 |
|
} |
1033 |
|
|
|
|
| 0% |
Uncovered Elements: 34 (34) |
Complexity: 10 |
Complexity Density: 0.59 |
|
1034 |
|
class ArgDisplayComparator implements Comparator<Arg> |
1035 |
|
{ |
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 4 |
Complexity Density: 2 |
|
1036 |
0 |
private int compareArgOpts(Arg a, Arg b, Opt o)... |
1037 |
|
{ |
1038 |
0 |
int i = a.hasOption(o) ? (b.hasOption(o) ? 0 : -1) |
1039 |
0 |
: (b.hasOption(o) ? 1 : 0); |
1040 |
0 |
return i; |
1041 |
|
} |
1042 |
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 5 |
Complexity Density: 0.36 |
|
1043 |
0 |
private int compareForDisplay(Arg a, Arg b)... |
1044 |
|
{ |
1045 |
0 |
if (b == null) |
1046 |
0 |
return -1; |
1047 |
|
|
1048 |
0 |
int i = a.getFirstType().compareTo(b.getFirstType()); |
1049 |
0 |
if (i != 0) |
1050 |
0 |
return i; |
1051 |
|
|
1052 |
0 |
i = compareArgOpts(b, a, Opt.LAST); |
1053 |
0 |
if (i != 0) |
1054 |
0 |
return i; |
1055 |
|
|
1056 |
0 |
Opt[] optOrder = { Opt.HELP, Opt.FIRST, Opt.PRIMARY, Opt.STRING, |
1057 |
|
Opt.BOOLEAN }; |
1058 |
0 |
for (Opt o : optOrder) |
1059 |
|
{ |
1060 |
0 |
i = compareArgOpts(a, b, o); |
1061 |
0 |
if (i != 0) |
1062 |
0 |
return i; |
1063 |
|
} |
1064 |
|
|
1065 |
0 |
return a.compareTo(b); |
1066 |
|
} |
1067 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1068 |
0 |
@Override... |
1069 |
|
public int compare(Arg a, Arg b) |
1070 |
|
{ |
1071 |
0 |
return compareForDisplay(a, b); |
1072 |
|
} |
1073 |
|
} |