2010-11-15 20:35:36 +00:00
|
|
|
/* ========================================================================
|
|
|
|
* PlantUML : a free UML diagram generator
|
|
|
|
* ========================================================================
|
|
|
|
*
|
2019-01-16 18:34:41 +00:00
|
|
|
* (C) Copyright 2009-2020, Arnaud Roques
|
2010-11-15 20:35:36 +00:00
|
|
|
*
|
2016-03-06 16:47:34 +00:00
|
|
|
* Project Info: http://plantuml.com
|
2010-11-15 20:35:36 +00:00
|
|
|
*
|
2017-03-15 19:13:31 +00:00
|
|
|
* If you like this project or if you find it useful, you can support us at:
|
|
|
|
*
|
|
|
|
* http://plantuml.com/patreon (only 1$ per month!)
|
|
|
|
* http://plantuml.com/paypal
|
|
|
|
*
|
2010-11-15 20:35:36 +00:00
|
|
|
* This file is part of PlantUML.
|
|
|
|
*
|
|
|
|
* PlantUML is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* PlantUML distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
2013-12-10 19:36:50 +00:00
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
2010-11-15 20:35:36 +00:00
|
|
|
* License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Original Author: Arnaud Roques
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
package net.sourceforge.plantuml;
|
|
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.FileReader;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.ArrayList;
|
2015-04-07 18:18:37 +00:00
|
|
|
import java.util.Arrays;
|
2010-11-15 20:35:36 +00:00
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
2017-04-05 17:37:42 +00:00
|
|
|
import net.sourceforge.plantuml.api.ApiWarning;
|
2016-05-31 19:41:55 +00:00
|
|
|
import net.sourceforge.plantuml.command.regex.Matcher2;
|
2015-04-07 18:18:37 +00:00
|
|
|
import net.sourceforge.plantuml.command.regex.MyPattern;
|
2016-05-31 19:41:55 +00:00
|
|
|
import net.sourceforge.plantuml.command.regex.Pattern2;
|
2016-04-04 19:05:10 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils;
|
2010-11-15 20:35:36 +00:00
|
|
|
import net.sourceforge.plantuml.preproc.Defines;
|
2020-05-30 15:20:23 +00:00
|
|
|
import net.sourceforge.plantuml.security.SFile;
|
2016-12-01 20:29:25 +00:00
|
|
|
import net.sourceforge.plantuml.stats.StatsUtils;
|
2010-11-15 20:35:36 +00:00
|
|
|
|
|
|
|
public class Option {
|
|
|
|
|
|
|
|
private final List<String> excludes = new ArrayList<String>();
|
|
|
|
private final List<String> config = new ArrayList<String>();
|
|
|
|
private final Map<String, String> defines = new LinkedHashMap<String, String>();
|
|
|
|
private String charset;
|
|
|
|
private boolean computeurl = false;
|
|
|
|
private boolean decodeurl = false;
|
|
|
|
private boolean pipe = false;
|
2017-03-21 21:37:59 +00:00
|
|
|
private String pipeDelimitor;
|
2016-11-04 21:39:29 +00:00
|
|
|
private boolean pipeMap = false;
|
2017-04-05 17:37:42 +00:00
|
|
|
private boolean pipeNoStdErr = false;
|
2010-11-15 20:35:36 +00:00
|
|
|
private boolean syntax = false;
|
2011-08-08 17:48:29 +00:00
|
|
|
private boolean checkOnly = false;
|
2018-07-27 21:56:46 +00:00
|
|
|
private OptionPreprocOutputMode preprocessorOutput = null;
|
2015-04-07 18:18:37 +00:00
|
|
|
private boolean failfast = false;
|
|
|
|
private boolean failfast2 = false;
|
2011-03-20 21:40:07 +00:00
|
|
|
private boolean pattern = false;
|
2011-08-08 17:48:29 +00:00
|
|
|
private boolean duration = false;
|
2016-05-11 21:31:47 +00:00
|
|
|
private boolean debugsvek = false;
|
2017-03-12 17:22:02 +00:00
|
|
|
private boolean splash = false;
|
|
|
|
private boolean textProgressBar = false;
|
2011-08-08 17:48:29 +00:00
|
|
|
private int nbThreads = 0;
|
|
|
|
private int ftpPort = -1;
|
2017-04-19 18:30:16 +00:00
|
|
|
private boolean hideMetadata = false;
|
2018-05-01 17:26:04 +00:00
|
|
|
private boolean checkMetadata = false;
|
2018-12-22 11:11:40 +00:00
|
|
|
private int stdrpt = 0;
|
2017-07-03 17:59:53 +00:00
|
|
|
private int imageIndex = 0;
|
2010-11-15 20:35:36 +00:00
|
|
|
|
|
|
|
private File outputDir = null;
|
2011-08-08 17:48:29 +00:00
|
|
|
private File outputFile = null;
|
2017-12-11 21:02:10 +00:00
|
|
|
private String filename;
|
2013-12-10 19:36:50 +00:00
|
|
|
|
2010-11-15 20:35:36 +00:00
|
|
|
private final List<String> result = new ArrayList<String>();
|
|
|
|
|
|
|
|
public Option() {
|
|
|
|
}
|
|
|
|
|
2017-04-05 17:37:42 +00:00
|
|
|
private FileFormatOption fileFormatOption = new FileFormatOption(FileFormat.PNG);
|
2010-11-15 20:35:36 +00:00
|
|
|
|
2017-04-05 17:37:42 +00:00
|
|
|
@Deprecated
|
|
|
|
@ApiWarning(willBeRemoved = "in next major release")
|
|
|
|
final public void setFileFormat(FileFormat fileFormat) {
|
|
|
|
setFileFormatOption(new FileFormatOption(fileFormat));
|
2010-11-15 20:35:36 +00:00
|
|
|
}
|
|
|
|
|
2017-04-05 17:37:42 +00:00
|
|
|
final public void setFileFormatOption(FileFormatOption newFormat) {
|
|
|
|
this.fileFormatOption = newFormat;
|
2010-11-15 20:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public Option(String... arg) throws InterruptedException, IOException {
|
|
|
|
if (arg.length == 0) {
|
|
|
|
OptionFlags.getInstance().setGui(true);
|
|
|
|
}
|
2019-02-09 21:56:24 +00:00
|
|
|
initInclude(GraphvizUtils.getenvDefaultConfigFilename());
|
2010-11-15 20:35:36 +00:00
|
|
|
for (int i = 0; i < arg.length; i++) {
|
|
|
|
String s = arg[i];
|
2018-06-12 20:50:45 +00:00
|
|
|
if (s.equalsIgnoreCase("-headless")) {
|
|
|
|
// Useless because done in Run.java
|
|
|
|
if (i != 0) {
|
|
|
|
Log.error("Warning: -headless flag must be the first one in the command line");
|
|
|
|
}
|
|
|
|
System.setProperty("java.awt.headless", "true");
|
|
|
|
} else if (s.equalsIgnoreCase("-tsvg") || s.equalsIgnoreCase("-svg")) {
|
2017-04-05 17:37:42 +00:00
|
|
|
setFileFormatOption(new FileFormatOption(FileFormat.SVG));
|
|
|
|
} else if (s.equalsIgnoreCase("-tsvg:nornd") || s.equalsIgnoreCase("-svg:nornd")) {
|
2017-04-19 18:30:16 +00:00
|
|
|
setFileFormatOption(new FileFormatOption(FileFormat.SVG));
|
2013-12-10 19:36:50 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-thtml") || s.equalsIgnoreCase("-html")) {
|
2017-04-05 17:37:42 +00:00
|
|
|
setFileFormatOption(new FileFormatOption(FileFormat.HTML));
|
2016-04-22 20:36:08 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-tscxml") || s.equalsIgnoreCase("-scxml")) {
|
2017-04-05 17:37:42 +00:00
|
|
|
setFileFormatOption(new FileFormatOption(FileFormat.SCXML));
|
2011-01-05 18:23:06 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-txmi") || s.equalsIgnoreCase("-xmi")) {
|
2017-04-05 17:37:42 +00:00
|
|
|
setFileFormatOption(new FileFormatOption(FileFormat.XMI_STANDARD));
|
2011-01-05 18:23:06 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-txmi:argo") || s.equalsIgnoreCase("-xmi:argo")) {
|
2017-04-05 17:37:42 +00:00
|
|
|
setFileFormatOption(new FileFormatOption(FileFormat.XMI_ARGO));
|
2011-01-05 18:23:06 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-txmi:star") || s.equalsIgnoreCase("-xmi:star")) {
|
2017-04-05 17:37:42 +00:00
|
|
|
setFileFormatOption(new FileFormatOption(FileFormat.XMI_STAR));
|
2010-11-15 20:35:36 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-teps") || s.equalsIgnoreCase("-eps")) {
|
2017-04-05 17:37:42 +00:00
|
|
|
setFileFormatOption(new FileFormatOption(FileFormat.EPS));
|
2011-08-08 17:48:29 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-teps:text") || s.equalsIgnoreCase("-eps:text")) {
|
2017-04-05 17:37:42 +00:00
|
|
|
setFileFormatOption(new FileFormatOption(FileFormat.EPS_TEXT));
|
2010-11-15 20:35:36 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-ttxt") || s.equalsIgnoreCase("-txt")) {
|
2017-04-05 17:37:42 +00:00
|
|
|
setFileFormatOption(new FileFormatOption(FileFormat.ATXT));
|
2010-11-15 20:35:36 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-tutxt") || s.equalsIgnoreCase("-utxt")) {
|
2017-04-05 17:37:42 +00:00
|
|
|
setFileFormatOption(new FileFormatOption(FileFormat.UTXT));
|
2016-08-25 20:45:37 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-braille") || s.equalsIgnoreCase("-tbraille")) {
|
2017-04-05 17:37:42 +00:00
|
|
|
setFileFormatOption(new FileFormatOption(FileFormat.BRAILLE_PNG));
|
2013-12-10 19:36:50 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-png") || s.equalsIgnoreCase("-tpng")) {
|
2017-04-05 17:37:42 +00:00
|
|
|
setFileFormatOption(new FileFormatOption(FileFormat.PNG));
|
2013-12-10 19:36:50 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-vdx") || s.equalsIgnoreCase("-tvdx")) {
|
2017-04-05 17:37:42 +00:00
|
|
|
setFileFormatOption(new FileFormatOption(FileFormat.VDX));
|
2015-04-07 18:18:37 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-latex") || s.equalsIgnoreCase("-tlatex")) {
|
2017-04-05 17:37:42 +00:00
|
|
|
setFileFormatOption(new FileFormatOption(FileFormat.LATEX));
|
2016-03-06 16:47:34 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-latex:nopreamble") || s.equalsIgnoreCase("-tlatex:nopreamble")) {
|
2017-04-05 17:37:42 +00:00
|
|
|
setFileFormatOption(new FileFormatOption(FileFormat.LATEX_NO_PREAMBLE));
|
2015-04-07 18:18:37 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-base64") || s.equalsIgnoreCase("-tbase64")) {
|
2017-04-05 17:37:42 +00:00
|
|
|
setFileFormatOption(new FileFormatOption(FileFormat.BASE64));
|
2011-08-08 17:48:29 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-pdf") || s.equalsIgnoreCase("-tpdf")) {
|
2017-04-05 17:37:42 +00:00
|
|
|
setFileFormatOption(new FileFormatOption(FileFormat.PDF));
|
2013-12-10 19:36:50 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-overwrite")) {
|
|
|
|
OptionFlags.getInstance().setOverwrite(true);
|
2010-11-15 20:35:36 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-output") || s.equalsIgnoreCase("-o")) {
|
|
|
|
i++;
|
|
|
|
if (i == arg.length) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
outputDir = new File(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]));
|
2011-08-08 17:48:29 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-ofile")) {
|
|
|
|
i++;
|
|
|
|
if (i == arg.length) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
outputFile = new File(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]));
|
2010-11-15 20:35:36 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-graphvizdot") || s.equalsIgnoreCase("-graphviz_dot")) {
|
|
|
|
i++;
|
|
|
|
if (i == arg.length) {
|
|
|
|
continue;
|
|
|
|
}
|
2016-04-04 19:05:10 +00:00
|
|
|
GraphvizUtils.setDotExecutable(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]));
|
2010-11-15 20:35:36 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-charset")) {
|
|
|
|
i++;
|
|
|
|
if (i == arg.length) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
charset = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]);
|
2017-12-11 21:02:10 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-filename")) {
|
|
|
|
i++;
|
|
|
|
if (i == arg.length) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
filename = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]);
|
2010-11-15 20:35:36 +00:00
|
|
|
} else if (s.startsWith("-o") && s.length() > 3) {
|
|
|
|
s = s.substring(2);
|
|
|
|
outputDir = new File(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s));
|
|
|
|
} else if (s.equalsIgnoreCase("-recurse") || s.equalsIgnoreCase("-r")) {
|
|
|
|
// recurse = true;
|
|
|
|
} else if (s.equalsIgnoreCase("-exclude") || s.equalsIgnoreCase("-x")) {
|
|
|
|
i++;
|
|
|
|
if (i == arg.length) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
excludes.add(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]));
|
2011-08-08 17:48:29 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-nbthread") || s.equalsIgnoreCase("-nbthreads")) {
|
|
|
|
i++;
|
|
|
|
if (i == arg.length) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
final String nb = arg[i];
|
|
|
|
if ("auto".equalsIgnoreCase(nb)) {
|
|
|
|
this.nbThreads = defaultNbThreads();
|
|
|
|
} else if (nb.matches("\\d+")) {
|
|
|
|
this.nbThreads = Integer.parseInt(nb);
|
|
|
|
}
|
2017-04-05 17:37:42 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-timeout")) {
|
|
|
|
i++;
|
|
|
|
if (i == arg.length) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
final String timeSeconds = arg[i];
|
|
|
|
if (timeSeconds.matches("\\d+")) {
|
|
|
|
OptionFlags.getInstance().setTimeoutMs(Integer.parseInt(timeSeconds) * 1000L);
|
|
|
|
}
|
2015-04-07 18:18:37 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-failfast")) {
|
|
|
|
this.failfast = true;
|
|
|
|
} else if (s.equalsIgnoreCase("-failfast2")) {
|
|
|
|
this.failfast2 = true;
|
2011-08-08 17:48:29 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-checkonly")) {
|
|
|
|
this.checkOnly = true;
|
2010-11-15 20:35:36 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-config")) {
|
|
|
|
i++;
|
|
|
|
if (i == arg.length) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
initConfig(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]));
|
2017-03-15 19:13:31 +00:00
|
|
|
} else if (s.startsWith("-I")) {
|
|
|
|
initInclude(s.substring(2));
|
2010-11-15 20:35:36 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-computeurl") || s.equalsIgnoreCase("-encodeurl")) {
|
|
|
|
this.computeurl = true;
|
|
|
|
} else if (s.startsWith("-x")) {
|
|
|
|
s = s.substring(2);
|
|
|
|
excludes.add(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s));
|
|
|
|
} else if (s.equalsIgnoreCase("-verbose") || s.equalsIgnoreCase("-v")) {
|
|
|
|
OptionFlags.getInstance().setVerbose(true);
|
|
|
|
} else if (s.equalsIgnoreCase("-pipe") || s.equalsIgnoreCase("-p")) {
|
|
|
|
pipe = true;
|
2017-03-21 21:37:59 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-pipedelimitor")) {
|
|
|
|
i++;
|
|
|
|
if (i == arg.length) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
pipeDelimitor = arg[i];
|
2016-11-04 21:39:29 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-pipemap")) {
|
|
|
|
pipeMap = true;
|
2017-04-05 17:37:42 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-pipenostderr")) {
|
|
|
|
pipeNoStdErr = true;
|
2011-03-20 21:40:07 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-pattern")) {
|
|
|
|
pattern = true;
|
2010-11-15 20:35:36 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-syntax")) {
|
|
|
|
syntax = true;
|
|
|
|
OptionFlags.getInstance().setQuiet(true);
|
2011-08-08 17:48:29 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-duration")) {
|
|
|
|
duration = true;
|
2016-05-11 21:31:47 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-debugsvek") || s.equalsIgnoreCase("-debug_svek")) {
|
|
|
|
debugsvek = true;
|
2010-11-15 20:35:36 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-keepfiles") || s.equalsIgnoreCase("-keepfile")) {
|
2016-05-11 21:31:47 +00:00
|
|
|
System.err.println("-keepfiles option has been removed. Please consider -debugsvek instead");
|
2010-11-15 20:35:36 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-metadata")) {
|
2017-04-19 18:30:16 +00:00
|
|
|
OptionFlags.getInstance().setExtractFromMetadata(true);
|
2011-08-08 17:48:29 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-logdata")) {
|
|
|
|
i++;
|
|
|
|
if (i == arg.length) {
|
|
|
|
continue;
|
|
|
|
}
|
2020-05-30 15:20:23 +00:00
|
|
|
OptionFlags.getInstance()
|
|
|
|
.setLogData(new SFile(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i])));
|
2010-11-15 20:35:36 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-word")) {
|
|
|
|
OptionFlags.getInstance().setWord(true);
|
|
|
|
OptionFlags.getInstance().setQuiet(true);
|
2017-07-03 17:59:53 +00:00
|
|
|
this.charset = "UTF-8";
|
2010-11-15 20:35:36 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-quiet")) {
|
|
|
|
OptionFlags.getInstance().setQuiet(true);
|
|
|
|
} else if (s.equalsIgnoreCase("-decodeurl")) {
|
|
|
|
this.decodeurl = true;
|
|
|
|
} else if (s.equalsIgnoreCase("-version")) {
|
|
|
|
OptionPrint.printVersion();
|
2013-12-10 19:36:50 +00:00
|
|
|
} else if (s.matches("(?i)^-li[sc][ea]n[sc]e\\s*$")) {
|
|
|
|
OptionPrint.printLicense();
|
2018-08-26 12:09:50 +00:00
|
|
|
} else if (s.startsWith("-DPLANTUML_LIMIT_SIZE=")) {
|
|
|
|
final String v = s.substring("-DPLANTUML_LIMIT_SIZE=".length());
|
|
|
|
if (v.matches("\\d+")) {
|
|
|
|
System.setProperty("PLANTUML_LIMIT_SIZE", v);
|
|
|
|
}
|
2010-11-15 20:35:36 +00:00
|
|
|
} else if (s.startsWith("-D")) {
|
|
|
|
manageDefine(s.substring(2));
|
2011-04-19 16:50:40 +00:00
|
|
|
} else if (s.startsWith("-S")) {
|
|
|
|
manageSkinParam(s.substring(2));
|
2010-11-15 20:35:36 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-testdot")) {
|
|
|
|
OptionPrint.printTestDot();
|
2020-05-30 15:20:23 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-about") || s.equalsIgnoreCase("-author")
|
|
|
|
|| s.equalsIgnoreCase("-authors")) {
|
2010-11-15 20:35:36 +00:00
|
|
|
OptionPrint.printAbout();
|
|
|
|
} else if (s.equalsIgnoreCase("-help") || s.equalsIgnoreCase("-h") || s.equalsIgnoreCase("-?")) {
|
|
|
|
OptionPrint.printHelp();
|
|
|
|
} else if (s.equalsIgnoreCase("-language")) {
|
|
|
|
OptionPrint.printLanguage();
|
|
|
|
} else if (s.equalsIgnoreCase("-gui")) {
|
|
|
|
OptionFlags.getInstance().setGui(true);
|
2013-12-10 19:36:50 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-encodesprite")) {
|
|
|
|
OptionFlags.getInstance().setEncodesprite(true);
|
2017-11-20 16:10:36 +00:00
|
|
|
// } else if (s.equalsIgnoreCase("-nosuggestengine")) {
|
|
|
|
// OptionFlags.getInstance().setUseSuggestEngine(false);
|
2011-08-08 17:48:29 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-printfonts")) {
|
|
|
|
OptionFlags.getInstance().setPrintFonts(true);
|
2016-12-01 20:29:25 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-dumphtmlstats")) {
|
|
|
|
OptionFlags.getInstance().setDumpHtmlStats(true);
|
|
|
|
} else if (s.equalsIgnoreCase("-dumpstats")) {
|
|
|
|
OptionFlags.getInstance().setDumpStats(true);
|
|
|
|
} else if (s.equalsIgnoreCase("-loopstats")) {
|
|
|
|
OptionFlags.getInstance().setLoopStats(true);
|
2016-12-14 21:01:03 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-enablestats")) {
|
|
|
|
OptionFlags.getInstance().setEnableStats(true);
|
|
|
|
} else if (s.equalsIgnoreCase("-disablestats")) {
|
|
|
|
OptionFlags.getInstance().setEnableStats(false);
|
2017-12-11 21:02:10 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-extractstdlib")) {
|
|
|
|
OptionFlags.getInstance().setExtractStdLib(true);
|
2018-06-12 20:50:45 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-stdlib")) {
|
|
|
|
OptionFlags.getInstance().setStdLib(true);
|
|
|
|
} else if (s.equalsIgnoreCase("-clipboard")) {
|
|
|
|
OptionFlags.getInstance().setClipboard(true);
|
|
|
|
} else if (s.equalsIgnoreCase("-clipboardloop")) {
|
|
|
|
OptionFlags.getInstance().setClipboardLoop(true);
|
2016-12-01 20:29:25 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-htmlstats")) {
|
|
|
|
StatsUtils.setHtmlStats(true);
|
|
|
|
} else if (s.equalsIgnoreCase("-xmlstats")) {
|
|
|
|
StatsUtils.setXmlStats(true);
|
|
|
|
} else if (s.equalsIgnoreCase("-realtimestats")) {
|
|
|
|
StatsUtils.setRealTimeStats(true);
|
|
|
|
} else if (s.equalsIgnoreCase("-useseparatorminus")) {
|
|
|
|
OptionFlags.getInstance().setFileSeparator("-");
|
2017-03-12 17:22:02 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-splash")) {
|
|
|
|
splash = true;
|
|
|
|
} else if (s.equalsIgnoreCase("-progress")) {
|
|
|
|
textProgressBar = true;
|
2017-04-19 18:30:16 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-nometadata")) {
|
|
|
|
hideMetadata = true;
|
2018-07-27 21:56:46 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-preproc")) {
|
|
|
|
preprocessorOutput = OptionPreprocOutputMode.NORMAL;
|
|
|
|
} else if (s.equalsIgnoreCase("-cypher")) {
|
|
|
|
preprocessorOutput = OptionPreprocOutputMode.CYPHER;
|
2018-05-01 17:26:04 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-checkmetadata")) {
|
|
|
|
checkMetadata = true;
|
2018-12-22 11:11:40 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-stdrpt:1")) {
|
|
|
|
stdrpt = 1;
|
|
|
|
} else if (s.equalsIgnoreCase("-stdrpt")) {
|
|
|
|
stdrpt = 1;
|
2017-07-03 17:59:53 +00:00
|
|
|
} else if (s.equalsIgnoreCase("-pipeimageindex")) {
|
|
|
|
i++;
|
|
|
|
if (i == arg.length) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
final String nb = arg[i];
|
|
|
|
if (nb.matches("\\d+")) {
|
|
|
|
this.imageIndex = Integer.parseInt(nb);
|
|
|
|
}
|
2015-04-07 18:18:37 +00:00
|
|
|
} else if (StringUtils.goLowerCase(s).startsWith("-ftp")) {
|
2011-08-08 17:48:29 +00:00
|
|
|
final int x = s.indexOf(':');
|
|
|
|
if (x == -1) {
|
|
|
|
this.ftpPort = 4242;
|
|
|
|
} else {
|
|
|
|
this.ftpPort = Integer.parseInt(s.substring(x + 1));
|
|
|
|
}
|
2013-12-10 19:36:50 +00:00
|
|
|
} else if (s.startsWith("-c")) {
|
|
|
|
s = s.substring(2);
|
|
|
|
config.add(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s));
|
2010-11-15 20:35:36 +00:00
|
|
|
} else {
|
|
|
|
result.add(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-22 11:11:40 +00:00
|
|
|
public Stdrpt getStdrpt() {
|
|
|
|
if (stdrpt == 1) {
|
|
|
|
return new StdrptV1();
|
|
|
|
}
|
|
|
|
// Legacy case
|
|
|
|
if (isPipe() || isPipeMap() || isSyntax()) {
|
|
|
|
return new StdrptPipe0();
|
|
|
|
}
|
|
|
|
return new StdrptNull();
|
|
|
|
}
|
|
|
|
|
2011-08-08 17:48:29 +00:00
|
|
|
public int getFtpPort() {
|
|
|
|
return ftpPort;
|
|
|
|
}
|
|
|
|
|
2020-05-30 15:20:23 +00:00
|
|
|
private void addInConfig(BufferedReader br) throws IOException {
|
|
|
|
if (br == null) {
|
|
|
|
return;
|
|
|
|
}
|
2010-11-15 20:35:36 +00:00
|
|
|
try {
|
|
|
|
String s = null;
|
|
|
|
while ((s = br.readLine()) != null) {
|
|
|
|
config.add(s);
|
|
|
|
}
|
|
|
|
} finally {
|
2020-05-30 15:20:23 +00:00
|
|
|
br.close();
|
2010-11-15 20:35:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-15 19:13:31 +00:00
|
|
|
public void initConfig(String filename) throws IOException {
|
2020-05-30 15:20:23 +00:00
|
|
|
final BufferedReader br = new BufferedReader(new FileReader(filename));
|
|
|
|
addInConfig(br);
|
2017-03-15 19:13:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void initInclude(String filename) throws IOException {
|
2019-02-09 21:56:24 +00:00
|
|
|
if (filename == null) {
|
|
|
|
return;
|
|
|
|
}
|
2017-03-15 19:13:31 +00:00
|
|
|
if (filename.contains("*")) {
|
2020-05-30 15:20:23 +00:00
|
|
|
final FileGroup group = new FileGroup(filename, Collections.<String>emptyList(), null);
|
2017-03-15 19:13:31 +00:00
|
|
|
for (File f : group.getFiles()) {
|
2019-02-09 21:56:24 +00:00
|
|
|
if (f.exists() && f.canRead()) {
|
2020-05-30 15:20:23 +00:00
|
|
|
addInConfig(new BufferedReader(new FileReader(f)));
|
2019-02-09 21:56:24 +00:00
|
|
|
}
|
2017-03-15 19:13:31 +00:00
|
|
|
}
|
|
|
|
} else {
|
2019-02-09 21:56:24 +00:00
|
|
|
final File f = new File(filename);
|
|
|
|
if (f.exists() && f.canRead()) {
|
2020-05-30 15:20:23 +00:00
|
|
|
addInConfig(new BufferedReader(new FileReader(f)));
|
2019-02-09 21:56:24 +00:00
|
|
|
}
|
2017-03-15 19:13:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-15 20:35:36 +00:00
|
|
|
private void manageDefine(String s) {
|
2016-05-31 19:41:55 +00:00
|
|
|
final Pattern2 p = MyPattern.cmpile("^(\\w+)(?:=(.*))?$");
|
|
|
|
final Matcher2 m = p.matcher(s);
|
2010-11-15 20:35:36 +00:00
|
|
|
if (m.find()) {
|
|
|
|
define(m.group(1), m.group(2));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-19 16:50:40 +00:00
|
|
|
private void manageSkinParam(String s) {
|
2016-05-31 19:41:55 +00:00
|
|
|
final Pattern2 p = MyPattern.cmpile("^(\\w+)(?:=(.*))?$");
|
|
|
|
final Matcher2 m = p.matcher(s);
|
2011-04-19 16:50:40 +00:00
|
|
|
if (m.find()) {
|
|
|
|
skinParam(m.group(1), m.group(2));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void skinParam(String var, String value) {
|
|
|
|
if (var != null && value != null) {
|
|
|
|
config.add("skinparamlocked " + var + " " + value);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-11-15 20:35:36 +00:00
|
|
|
public final File getOutputDir() {
|
|
|
|
return outputDir;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final static String getPattern() {
|
2020-04-19 16:04:39 +00:00
|
|
|
return "(?i)^.*\\.(txt|tex|java|htm|html|c|h|cpp|apt|pu|puml|hpp|hh)$";
|
2010-11-15 20:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setOutputDir(File f) {
|
|
|
|
outputDir = f;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final List<String> getExcludes() {
|
|
|
|
return Collections.unmodifiableList(excludes);
|
|
|
|
}
|
|
|
|
|
2020-05-30 15:20:23 +00:00
|
|
|
public Defines getDefaultDefines(SFile f) {
|
|
|
|
final Defines result = Defines.createWithFileName(f);
|
|
|
|
for (Map.Entry<String, String> ent : defines.entrySet()) {
|
|
|
|
String value = ent.getValue();
|
|
|
|
if (value == null) {
|
|
|
|
value = "";
|
|
|
|
}
|
|
|
|
result.define(ent.getKey(), Arrays.asList(value), false, null);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Defines getDefaultDefines(java.io.File f) {
|
2017-04-05 17:37:42 +00:00
|
|
|
final Defines result = Defines.createWithFileName(f);
|
2010-11-15 20:35:36 +00:00
|
|
|
for (Map.Entry<String, String> ent : defines.entrySet()) {
|
2020-01-12 22:13:17 +00:00
|
|
|
String value = ent.getValue();
|
|
|
|
if (value == null) {
|
|
|
|
value = "";
|
|
|
|
}
|
|
|
|
result.define(ent.getKey(), Arrays.asList(value), false, null);
|
2018-01-04 22:32:45 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2010-11-15 20:35:36 +00:00
|
|
|
|
2018-01-04 22:32:45 +00:00
|
|
|
public Defines getDefaultDefines() {
|
|
|
|
final Defines result = Defines.createEmpty();
|
|
|
|
result.overrideFilename(filename);
|
|
|
|
for (Map.Entry<String, String> ent : defines.entrySet()) {
|
2018-12-22 11:11:40 +00:00
|
|
|
result.define(ent.getKey(), Arrays.asList(ent.getValue()), false, null);
|
2010-11-15 20:35:36 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void define(String name, String value) {
|
|
|
|
defines.put(name, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<String> getConfig() {
|
|
|
|
return Collections.unmodifiableList(config);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final List<String> getResult() {
|
|
|
|
return Collections.unmodifiableList(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final String getCharset() {
|
|
|
|
return charset;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCharset(String s) {
|
|
|
|
this.charset = s;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean isComputeurl() {
|
|
|
|
return computeurl;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean isDecodeurl() {
|
|
|
|
return decodeurl;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean isPipe() {
|
|
|
|
return pipe;
|
|
|
|
}
|
|
|
|
|
2016-11-04 21:39:29 +00:00
|
|
|
public final boolean isPipeMap() {
|
|
|
|
return pipeMap;
|
|
|
|
}
|
|
|
|
|
2010-11-15 20:35:36 +00:00
|
|
|
public final boolean isSyntax() {
|
|
|
|
return syntax;
|
|
|
|
}
|
|
|
|
|
2011-03-20 21:40:07 +00:00
|
|
|
public final boolean isPattern() {
|
|
|
|
return pattern;
|
|
|
|
}
|
|
|
|
|
2011-01-05 18:23:06 +00:00
|
|
|
public FileFormatOption getFileFormatOption() {
|
2016-05-11 21:31:47 +00:00
|
|
|
if (debugsvek) {
|
|
|
|
fileFormatOption.setDebugSvek(true);
|
|
|
|
}
|
2017-04-19 18:30:16 +00:00
|
|
|
if (hideMetadata) {
|
|
|
|
fileFormatOption.hideMetadata();
|
|
|
|
}
|
2016-05-11 21:31:47 +00:00
|
|
|
return fileFormatOption;
|
2011-01-05 18:23:06 +00:00
|
|
|
}
|
|
|
|
|
2011-08-08 17:48:29 +00:00
|
|
|
public final boolean isDuration() {
|
|
|
|
return duration;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final int getNbThreads() {
|
|
|
|
return nbThreads;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void setNbThreads(int nb) {
|
|
|
|
this.nbThreads = nb;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int defaultNbThreads() {
|
|
|
|
return Runtime.getRuntime().availableProcessors();
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean isCheckOnly() {
|
|
|
|
return checkOnly;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void setCheckOnly(boolean checkOnly) {
|
|
|
|
this.checkOnly = checkOnly;
|
|
|
|
}
|
|
|
|
|
2015-04-07 18:18:37 +00:00
|
|
|
public final boolean isFailfastOrFailfast2() {
|
|
|
|
return failfast || failfast2;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean isFailfast2() {
|
|
|
|
return failfast2;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void setFailfast(boolean failfast) {
|
|
|
|
this.failfast = failfast;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void setFailfast2(boolean failfast2) {
|
|
|
|
this.failfast2 = failfast2;
|
|
|
|
}
|
|
|
|
|
2011-08-08 17:48:29 +00:00
|
|
|
public final File getOutputFile() {
|
|
|
|
return outputFile;
|
|
|
|
}
|
|
|
|
|
2016-05-11 21:31:47 +00:00
|
|
|
public final void setDebugSvek(boolean debugsvek) {
|
|
|
|
this.debugsvek = debugsvek;
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean isDebugSvek() {
|
|
|
|
return debugsvek;
|
|
|
|
}
|
|
|
|
|
2017-03-12 17:22:02 +00:00
|
|
|
public final boolean isSplash() {
|
|
|
|
return splash;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void setSplash(boolean splash) {
|
|
|
|
this.splash = splash;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean isTextProgressBar() {
|
|
|
|
return textProgressBar;
|
|
|
|
}
|
|
|
|
|
2017-03-21 21:37:59 +00:00
|
|
|
public String getPipeDelimitor() {
|
|
|
|
return pipeDelimitor;
|
|
|
|
}
|
|
|
|
|
2017-04-05 17:37:42 +00:00
|
|
|
public final boolean isPipeNoStdErr() {
|
|
|
|
return pipeNoStdErr;
|
|
|
|
}
|
|
|
|
|
2017-07-03 17:59:53 +00:00
|
|
|
public final int getImageIndex() {
|
|
|
|
return imageIndex;
|
|
|
|
}
|
|
|
|
|
2017-12-11 21:02:10 +00:00
|
|
|
public final void setFilename(String filename) {
|
|
|
|
this.filename = filename;
|
|
|
|
}
|
|
|
|
|
2018-05-01 17:26:04 +00:00
|
|
|
public final boolean isCheckMetadata() {
|
|
|
|
return checkMetadata;
|
|
|
|
}
|
|
|
|
|
2018-07-27 21:56:46 +00:00
|
|
|
public final OptionPreprocOutputMode getPreprocessorOutputMode() {
|
|
|
|
return preprocessorOutput;
|
|
|
|
}
|
|
|
|
|
|
|
|
// public final void setPreprocessorOutput(boolean preprocessorOutput) {
|
|
|
|
// this.preprocessorOutput = preprocessorOutput;
|
|
|
|
// }
|
|
|
|
|
2010-11-15 20:35:36 +00:00
|
|
|
}
|