code: protected void runScript(File script) {
          if (!script.exists()) {
              JOptionPane.showMessageDialog(cliGuiCtx.getMainPanel(), script.getAbsolutePath() + " does not exist.",
                                            "Unable to run script.", JOptionPane.ERROR_MESSAGE);
              return;
          }
  
          int choice = JOptionPane.showConfirmDialog(cliGuiCtx.getMainPanel(), "Run CLI script " + script.getName() + "?",
                                                     "Confirm run script", JOptionPane.YES_NO_OPTION);
          if (choice != JOptionPane.YES_OPTION) return;
  
          menu.addScript(script);
  
          cliGuiCtx.getTabs().setSelectedIndex(1); // set to Output tab to view the output
          output.post("\n");
  
          SwingWorker scriptRunner = new ScriptRunner(script);
          scriptRunner.execute();
      }
docs: Run a CLI script from a File.
  
  @param script The script file.