package com.microchip.mplab.ipecmd; import com.microchip.mplab.ipecmd.commandline.CmdApp; import com.microchip.mplab.ipecmd.common.SharedData; import com.microchip.mplab.progcli.PackPaths; import java.io.IOException; /** * Legacy ipecmd entry point, retained as a behavioural baseline for the modern * driver in {@link com.microchip.mplab.progcli}. * * Differences from stock MPLAB X ipecmd: * - socket-server mode removed (was used only by the IPE GUI) * - PM5CLI path removed (already dead code upstream: isPM5CLIToolpart() * returned false unconditionally in 6.35) * - pack locations resolved via {@link PackPaths} instead of being derived * from the ipecmd.jar install path */ public class IPECMD { private static CmdApp cmdapp; private static SharedData sharedData; private static void initApplication() { sharedData = SharedData.getSingletonObject(); sharedData.setSystemOutFilter(); sharedData.setSystemErrorFilter(); IPEEvents ipeEvent = new IPEEvents(); ipeEvent.addObserver(); } private static void performCommandLineOperation(String[] args) { cmdapp = new CmdApp(); sharedData.setLastErrorCode(0); try { cmdapp.runApplication(args); int errorCode = sharedData.getLastErrorCode(); if (errorCode == 0) { sharedData.IPEPrint("Operation Succeeded"); } System.exit(errorCode); } catch (IOException var3) { System.out.print("IPE:IOException: Something went wrong. \n"); } } /** * Shared bootstrap for both entry points: installs pack locations, * wires up the event listener, then hands the (already translated) * legacy-style argument vector to the engine. Exits the VM. */ public static void execute(String[] args) { PackPaths.install(); initApplication(); if (args.length == 0) { System.err.println("no arguments given"); System.exit(2); } performCommandLineOperation(args); } public static void main(String[] args) { execute(args); } }