Files
packwiz-installer/src/main/java/link/infra/packwiz/installer/RequiresBootstrap.java
2022-02-21 22:15:10 +00:00

38 lines
1.1 KiB
Java

package link.infra.packwiz.installer;
import javax.swing.*;
import java.util.Arrays;
public class RequiresBootstrap {
public static void main(String[] args) {
// Very small CLI implementation, because Commons CLI complains on unexpected
// options
if (Arrays.stream(args).map(str -> {
if (str == null) return "";
if (str.startsWith("--")) {
return str.substring(2);
}
if (str.startsWith("-")) {
return str.substring(1);
}
return "";
}).anyMatch(str -> str.equals("g") || str.equals("no-gui"))) {
System.out.println(
"This program must be run through packwiz-installer-bootstrap. Use --bootstrap-no-update to disable updating.");
System.exit(1);
} else {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
// Ignore the exceptions, just continue using the ugly L&F
}
JOptionPane.showMessageDialog(null,
"This program must be run through packwiz-installer-bootstrap. Use --bootstrap-no-update to disable updating.",
"packwiz-installer", JOptionPane.ERROR_MESSAGE);
System.exit(1);
}
}
}