@Override
	public void launch(GhidraApplicationLayout layout, String[] args) throws Exception {

		if (args.length != 1) {
			usage();
			System.exit(0);
		}
		String logFile = null; //TODO get from arguments?
		GhidraScriptUtil.initialize(new BundleHost(), scriptPaths);
		try {
			initialize(layout, logFile, true);
			runScript(args[0]);
		}
		finally {
			GhidraScriptUtil.dispose();
		}
	}
A simple class for running scripts outside of Ghidra.
Ghidra/Features/Base/src/main/java/ghidra/app/util/headless/GhidraScriptRunner.java