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);
|
||||
}
|
||||
|
||||
if (isHeadless()) {
|
||||
log.info(String.format("%s / %s (headless)%n%n%s", getApplicationIdentifier(), getJavaRuntimeIdentifier(), args.usage()));
|
||||
System.exit(1);
|
||||
// CLI behaviour for console interactive usage
|
||||
if (isHeadless() || System.console() != null) {
|
||||
// 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
|
||||
@ -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 {
|
||||
// publish file arguments
|
||||
List<File> files = args.getFiles(false);
|
||||
@ -162,17 +188,8 @@ public class Main {
|
||||
SwingEventBus.getInstance().post(new FileTransferable(files));
|
||||
}
|
||||
|
||||
// import license if started with license file
|
||||
if (LicenseModel.PGPSignedMessage == LICENSE) {
|
||||
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());
|
||||
}
|
||||
});
|
||||
}
|
||||
// import license if launched with license file
|
||||
configureLicense(args);
|
||||
|
||||
// JavaFX is used for ProgressMonitor and GettingStartedDialog
|
||||
try {
|
||||
|
@ -351,8 +351,8 @@ public class ArgumentBean {
|
||||
}).orElseThrow(error("Illegal mode", mode));
|
||||
}
|
||||
|
||||
public Optional<File> getLicenseFile() {
|
||||
return optional(license).map(File::new);
|
||||
public File getLicenseFile() {
|
||||
return license == null ? null : new File(license);
|
||||
}
|
||||
|
||||
private final String[] args;
|
||||
|
@ -21,17 +21,17 @@ public class ArgumentProcessor {
|
||||
// interactive mode enables basic selection and confirmation dialogs in the CLI
|
||||
CmdlineInterface cli = args.isInteractive() ? new CmdlineOperationsTextUI() : new CmdlineOperations();
|
||||
|
||||
// execute simple command
|
||||
if (args.script == null) {
|
||||
// execute command
|
||||
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) {
|
||||
if (findCause(e, CmdlineException.class) != null) {
|
||||
log.log(Level.WARNING, findCause(e, CmdlineException.class).getMessage());
|
||||
|
Loading…
x
Reference in New Issue
Block a user