mirror of
https://github.com/octoleo/plantuml.git
synced 2024-12-22 19:09:03 +00:00
fix: improve return code management
This commit is contained in:
parent
9a3c27eebf
commit
0f9f96dade
@ -62,13 +62,12 @@ public class OptionPrint {
|
|||||||
static public void printTestDot() throws InterruptedException {
|
static public void printTestDot() throws InterruptedException {
|
||||||
final List<String> result = new ArrayList<>();
|
final List<String> result = new ArrayList<>();
|
||||||
final int errorCode = GraphvizUtils.addDotStatus(result, false);
|
final int errorCode = GraphvizUtils.addDotStatus(result, false);
|
||||||
for (String s : result) {
|
for (String s : result)
|
||||||
if (errorCode == 0) {
|
if (errorCode == 0)
|
||||||
System.out.println(s);
|
System.out.println(s);
|
||||||
} else {
|
else
|
||||||
System.err.println(s);
|
System.err.println(s);
|
||||||
}
|
|
||||||
}
|
|
||||||
exit(errorCode);
|
exit(errorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,35 +168,34 @@ public class OptionPrint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static private void exit(int errorCode) throws InterruptedException {
|
static private void exit(int errorCode) throws InterruptedException {
|
||||||
if (OptionFlags.getInstance().isSystemExit() || errorCode != 0) {
|
if (OptionFlags.getInstance().isSystemExit() || errorCode != 0)
|
||||||
System.exit(errorCode);
|
System.exit(errorCode);
|
||||||
}
|
|
||||||
throw new InterruptedException("exit");
|
throw new InterruptedException("exit");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void printLicense() throws InterruptedException {
|
public static void printLicense() throws InterruptedException {
|
||||||
for (String s : License.getCurrent().getTextFull()) {
|
for (String s : License.getCurrent().getTextFull())
|
||||||
System.out.println(s);
|
System.out.println(s);
|
||||||
}
|
System.exit(0);
|
||||||
exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void printVersion() throws InterruptedException {
|
public static void printVersion() throws InterruptedException {
|
||||||
System.out.println(Version.fullDescription());
|
System.out.println(Version.fullDescription());
|
||||||
System.out.println("(" + License.getCurrent() + " source distribution)");
|
System.out.println("(" + License.getCurrent() + " source distribution)");
|
||||||
for (String v : interestingProperties()) {
|
for (String v : interestingProperties())
|
||||||
System.out.println(v);
|
System.out.println(v);
|
||||||
}
|
|
||||||
for (String v : interestingValues()) {
|
for (String v : interestingValues())
|
||||||
System.out.println(v);
|
System.out.println(v);
|
||||||
}
|
|
||||||
System.out.println();
|
System.out.println();
|
||||||
final List<String> result = new ArrayList<>();
|
final List<String> result = new ArrayList<>();
|
||||||
final int errorCode = GraphvizUtils.addDotStatus(result, false);
|
final int errorCode = GraphvizUtils.addDotStatus(result, false);
|
||||||
for (String s : result) {
|
for (String s : result)
|
||||||
System.out.println(s);
|
System.out.println(s);
|
||||||
}
|
|
||||||
exit(errorCode);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<String> interestingProperties() {
|
public static Collection<String> interestingProperties() {
|
||||||
|
@ -87,14 +87,10 @@ public class Run {
|
|||||||
throws NoPlantumlCompressionException, IOException, InterruptedException {
|
throws NoPlantumlCompressionException, IOException, InterruptedException {
|
||||||
System.setProperty("log4j.debug", "false");
|
System.setProperty("log4j.debug", "false");
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
if (argsArray.length > 0 && argsArray[0].equalsIgnoreCase("-headless")) {
|
if (argsArray.length > 0 && argsArray[0].equalsIgnoreCase("-headless"))
|
||||||
System.setProperty("java.awt.headless", "true");
|
System.setProperty("java.awt.headless", "true");
|
||||||
}
|
|
||||||
// if (argsArray.length > 0 && argsArray[0].equalsIgnoreCase("--de")) {
|
|
||||||
// debugGantt();
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
saveCommandLine(argsArray);
|
saveCommandLine(argsArray);
|
||||||
|
|
||||||
final Option option = new Option(argsArray);
|
final Option option = new Option(argsArray);
|
||||||
ProgressBar.setEnable(option.isTextProgressBar());
|
ProgressBar.setEnable(option.isTextProgressBar());
|
||||||
if (OptionFlags.getInstance().isClipboardLoop()) {
|
if (OptionFlags.getInstance().isClipboardLoop()) {
|
||||||
@ -156,9 +152,9 @@ public class Run {
|
|||||||
}
|
}
|
||||||
|
|
||||||
forceOpenJdkResourceLoad();
|
forceOpenJdkResourceLoad();
|
||||||
if (option.getPreprocessorOutputMode() == OptionPreprocOutputMode.CYPHER) {
|
if (option.getPreprocessorOutputMode() == OptionPreprocOutputMode.CYPHER)
|
||||||
cypher = new LanguageDescriptor().getCypher();
|
cypher = new LanguageDescriptor().getCypher();
|
||||||
}
|
|
||||||
final ErrorStatus error = ErrorStatus.init();
|
final ErrorStatus error = ErrorStatus.init();
|
||||||
boolean forceQuit = false;
|
boolean forceQuit = false;
|
||||||
if (OptionFlags.getInstance().isGui()) {
|
if (OptionFlags.getInstance().isGui()) {
|
||||||
@ -170,9 +166,9 @@ public class Run {
|
|||||||
File dir = null;
|
File dir = null;
|
||||||
if (list.size() == 1) {
|
if (list.size() == 1) {
|
||||||
final File f = new File(list.get(0));
|
final File f = new File(list.get(0));
|
||||||
if (f.exists() && f.isDirectory()) {
|
if (f.exists() && f.isDirectory())
|
||||||
dir = f;
|
dir = f;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
new MainWindow(option, dir);
|
new MainWindow(option, dir);
|
||||||
@ -187,9 +183,9 @@ public class Run {
|
|||||||
managePipe(option, error);
|
managePipe(option, error);
|
||||||
forceQuit = true;
|
forceQuit = true;
|
||||||
} else if (option.isFailfast2()) {
|
} else if (option.isFailfast2()) {
|
||||||
if (option.isSplash()) {
|
if (option.isSplash())
|
||||||
Splash.createSplash();
|
Splash.createSplash();
|
||||||
}
|
|
||||||
final long start2 = System.currentTimeMillis();
|
final long start2 = System.currentTimeMillis();
|
||||||
option.setCheckOnly(true);
|
option.setCheckOnly(true);
|
||||||
manageAllFiles(option, error);
|
manageAllFiles(option, error);
|
||||||
@ -198,14 +194,14 @@ public class Run {
|
|||||||
final double duration = (System.currentTimeMillis() - start2) / 1000.0;
|
final double duration = (System.currentTimeMillis() - start2) / 1000.0;
|
||||||
Log.error("Check Duration = " + duration + " seconds");
|
Log.error("Check Duration = " + duration + " seconds");
|
||||||
}
|
}
|
||||||
if (error.hasError() == false) {
|
if (error.hasError() == false)
|
||||||
manageAllFiles(option, error);
|
manageAllFiles(option, error);
|
||||||
}
|
|
||||||
forceQuit = true;
|
forceQuit = true;
|
||||||
} else {
|
} else {
|
||||||
if (option.isSplash()) {
|
if (option.isSplash())
|
||||||
Splash.createSplash();
|
Splash.createSplash();
|
||||||
}
|
|
||||||
manageAllFiles(option, error);
|
manageAllFiles(option, error);
|
||||||
forceQuit = true;
|
forceQuit = true;
|
||||||
}
|
}
|
||||||
@ -216,16 +212,15 @@ public class Run {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (OptionFlags.getInstance().isGui() == false) {
|
if (OptionFlags.getInstance().isGui() == false) {
|
||||||
if (error.hasError() || error.isNoData()) {
|
if (error.hasError() || error.isNoData())
|
||||||
option.getStdrpt().finalMessage(error);
|
option.getStdrpt().finalMessage(error);
|
||||||
}
|
|
||||||
if (error.hasError()) {
|
|
||||||
System.exit(error.getExitCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (forceQuit && OptionFlags.getInstance().isSystemExit()) {
|
if (error.hasError())
|
||||||
|
System.exit(error.getExitCode());
|
||||||
|
|
||||||
|
if (forceQuit && OptionFlags.getInstance().isSystemExit())
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,6 +159,12 @@ final public class UmlSource {
|
|||||||
// return Collections.unmodifiableCollection(rawSource).iterator();
|
// return Collections.unmodifiableCollection(rawSource).iterator();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
@Deprecated()
|
||||||
|
public String getPlainString() {
|
||||||
|
return getPlainString("\n");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the source as a single String.
|
* Return the source as a single String.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user