Refactor argument handling a bit
This commit is contained in:
parent
f078aae747
commit
7151227222
@ -65,14 +65,14 @@ public class Main {
|
||||
// parse arguments
|
||||
ArgumentBean args = new ArgumentBean(argv);
|
||||
|
||||
if (args.printHelp() || args.printVersion() || (!(args.runCLI() || args.clearCache() || args.clearUserData()) && isHeadless())) {
|
||||
log.info(format("%s / %s%n", getApplicationIdentifier(), getJavaRuntimeIdentifier()));
|
||||
// just print help message or version string and then exit
|
||||
if (args.printHelp()) {
|
||||
log.info(String.format("%s%n%n%s", getApplicationIdentifier(), args.usage()));
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
if (args.printHelp() || (!args.printVersion() && isHeadless())) {
|
||||
log.info(args.usage());
|
||||
}
|
||||
|
||||
// just print help message or version string and then exit
|
||||
if (args.printVersion()) {
|
||||
log.info(String.join(" / ", getApplicationIdentifier(), getJavaRuntimeIdentifier(), getSystemIdentifier()));
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@ -125,6 +125,11 @@ public class Main {
|
||||
System.exit(status);
|
||||
}
|
||||
|
||||
if (isHeadless()) {
|
||||
log.info(String.format("%s / %s (headless)%n%n%s", getApplicationIdentifier(), getJavaRuntimeIdentifier(), args.usage()));
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
// GUI mode => start user interface
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
startUserInterface(args);
|
||||
|
@ -2,7 +2,6 @@ package net.filebot;
|
||||
|
||||
import static net.filebot.Logging.*;
|
||||
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.io.File;
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
@ -176,7 +175,11 @@ public final class Settings {
|
||||
}
|
||||
|
||||
public static String getJavaRuntimeIdentifier() {
|
||||
return String.format("%s %s %s", System.getProperty("java.runtime.name"), System.getProperty("java.version"), GraphicsEnvironment.isHeadless() ? "(headless)" : "").trim();
|
||||
return String.format("%s %s", System.getProperty("java.runtime.name"), System.getProperty("java.version"));
|
||||
}
|
||||
|
||||
public static String getSystemIdentifier() {
|
||||
return String.format("%s %s (%s)", System.getProperty("os.name"), System.getProperty("os.version"), System.getProperty("os.arch"));
|
||||
}
|
||||
|
||||
private static ArgumentBean applicationArguments;
|
||||
|
Loading…
Reference in New Issue
Block a user