Command line initializer for Recaf, invoked from the main method. Sets up the controller to use then starts it. @author Matt
| 28 | * @author Matt |
| 29 | */ |
| 30 | @Command( |
| 31 | name = "Recaf", |
| 32 | version = Recaf.VERSION, |
| 33 | description = "Recaf: A modern java bytecode editor.", |
| 34 | mixinStandardHelpOptions = true) |
| 35 | public class Initializer implements Runnable { |
| 36 | @Option(names = {"--input" }, description = "The input file to load. " + |
| 37 | "Supported types are: class, jar, json") |
| 38 | public Path input; |
| 39 | @Option(names = {"--script" }, description = "Script file to load for cli usage") |
| 40 | public Path script; |
| 41 | @Option(names = { "--cli" }, description = "Run Recaf via CLI") |
| 42 | public boolean cli; |
| 43 | @Option(names = { "--instrument" }, description = "Indicates Recaf has been invoked as an agent") |
| 44 | public boolean instrument; |
| 45 | @Option(names = { "--noupdate" }, description = "Disable update checking entirely") |
| 46 | public boolean noUpdates; |
| 47 | // |
| 48 | private Controller controller; |
| 49 | |
| 50 | @Override |
| 51 | public void run() { |
| 52 | // Disable update check |
| 53 | if (noUpdates) |
| 54 | SelfUpdater.disable(); |
| 55 | // Setup controller |
| 56 | boolean headless = isHeadless(); |
| 57 | if (headless) |
| 58 | controller = new HeadlessController(input, script); |
| 59 | else |
| 60 | controller = new GuiController(input); |
| 61 | controller.setup(); |
| 62 | Recaf.setController(controller); |
| 63 | if (instrument) |
| 64 | InstrumentationResource.setup(controller); |
| 65 | else if (controller.config().backend().firstTime && script == null) |
| 66 | promptFirstTime(); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Start the controller. |
| 71 | */ |
| 72 | public void startController() { |
| 73 | controller.run(); |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Show documentation nag. |
| 78 | */ |
| 79 | private void promptFirstTime() { |
| 80 | // Unmark value |
| 81 | controller.config().backend().firstTime = false; |
| 82 | // Determine how to show prompt |
| 83 | if (isHeadless()) { |
| 84 | Log.info(LangUtil.translate("misc.firsttime.cli")); |
| 85 | String line = new Scanner(System.in).nextLine(); |
| 86 | if (line != null) { |
| 87 | line = line.trim().toLowerCase(); |
nothing calls this directly
no outgoing calls
no test coverage detected