mirror of
https://github.com/mitb-archive/filebot
synced 2025-03-09 22:09:47 -04:00
Experiment with PGP signed messages
This commit is contained in:
parent
bb6b6f244d
commit
f0a59d51f0
@ -117,9 +117,18 @@ public class Main {
|
|||||||
System.exit(status);
|
System.exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isHeadless()) {
|
// CLI behaviour for console interactive usage
|
||||||
log.info(String.format("%s / %s (headless)%n%n%s", getApplicationIdentifier(), getJavaRuntimeIdentifier(), args.usage()));
|
if (isHeadless() || System.console() != null) {
|
||||||
System.exit(1);
|
// print license to console if we have an interactive console
|
||||||
|
if (configureLicense(args)) {
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// exit with man page if we can't launch the GUI
|
||||||
|
if (isHeadless()) {
|
||||||
|
log.info(String.format("%s / %s (headless)%n%n%s", getApplicationIdentifier(), getJavaRuntimeIdentifier(), args.usage()));
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GUI mode => start user interface
|
// GUI mode => start user interface
|
||||||
@ -155,6 +164,23 @@ public class Main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean configureLicense(ArgumentBean args) {
|
||||||
|
File file = args.getLicenseFile();
|
||||||
|
|
||||||
|
if (file == null || LICENSE != LicenseModel.PGPSignedMessage) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
License license = License.configure(file);
|
||||||
|
log.info(license + " has been activated.");
|
||||||
|
} catch (Throwable e) {
|
||||||
|
log.severe("License Error: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private static void onStart(ArgumentBean args) throws Exception {
|
private static void onStart(ArgumentBean args) throws Exception {
|
||||||
// publish file arguments
|
// publish file arguments
|
||||||
List<File> files = args.getFiles(false);
|
List<File> files = args.getFiles(false);
|
||||||
@ -162,17 +188,8 @@ public class Main {
|
|||||||
SwingEventBus.getInstance().post(new FileTransferable(files));
|
SwingEventBus.getInstance().post(new FileTransferable(files));
|
||||||
}
|
}
|
||||||
|
|
||||||
// import license if started with license file
|
// import license if launched with license file
|
||||||
if (LicenseModel.PGPSignedMessage == LICENSE) {
|
configureLicense(args);
|
||||||
args.getLicenseFile().ifPresent(f -> {
|
|
||||||
try {
|
|
||||||
License license = License.configure(f);
|
|
||||||
log.info(license + " has been activated.");
|
|
||||||
} catch (Throwable e) {
|
|
||||||
log.severe("License Error: " + e.getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// JavaFX is used for ProgressMonitor and GettingStartedDialog
|
// JavaFX is used for ProgressMonitor and GettingStartedDialog
|
||||||
try {
|
try {
|
||||||
|
@ -351,8 +351,8 @@ public class ArgumentBean {
|
|||||||
}).orElseThrow(error("Illegal mode", mode));
|
}).orElseThrow(error("Illegal mode", mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<File> getLicenseFile() {
|
public File getLicenseFile() {
|
||||||
return optional(license).map(File::new);
|
return license == null ? null : new File(license);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String[] args;
|
private final String[] args;
|
||||||
|
@ -21,17 +21,17 @@ public class ArgumentProcessor {
|
|||||||
// interactive mode enables basic selection and confirmation dialogs in the CLI
|
// interactive mode enables basic selection and confirmation dialogs in the CLI
|
||||||
CmdlineInterface cli = args.isInteractive() ? new CmdlineOperationsTextUI() : new CmdlineOperations();
|
CmdlineInterface cli = args.isInteractive() ? new CmdlineOperationsTextUI() : new CmdlineOperations();
|
||||||
|
|
||||||
|
// execute simple command
|
||||||
if (args.script == null) {
|
if (args.script == null) {
|
||||||
// execute command
|
|
||||||
return runCommand(cli, args);
|
return runCommand(cli, args);
|
||||||
} else {
|
|
||||||
// execute user script
|
|
||||||
runScript(cli, args);
|
|
||||||
|
|
||||||
// script finished successfully
|
|
||||||
log.finest("Done ヾ(@⌒ー⌒@)ノ");
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// execute user script
|
||||||
|
runScript(cli, args);
|
||||||
|
|
||||||
|
// script finished successfully
|
||||||
|
log.finest("Done ヾ(@⌒ー⌒@)ノ");
|
||||||
|
return 0;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
if (findCause(e, CmdlineException.class) != null) {
|
if (findCause(e, CmdlineException.class) != null) {
|
||||||
log.log(Level.WARNING, findCause(e, CmdlineException.class).getMessage());
|
log.log(Level.WARNING, findCause(e, CmdlineException.class).getMessage());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user