@NotNull public static com.intellij.execution.process.ProcessOutput getProcessOutput(int timeout, @Nullable String workDir, @NotNull String exePath, @NotNull String... arguments) throws ExecutionException{ if(workDir == null || !new File(workDir).isDirectory() || !new File(exePath).canExecute()){ return new com.intellij.execution.process.ProcessOutput(); } GeneralCommandLine cmd = new GeneralCommandLine().withCharset(Charsets.UTF_8); cmd.withWorkDirectory(workDir); cmd.setExePath(exePath); cmd.addParameters(arguments); return execute(cmd, timeout); }
@NotNull private static GeneralCommandLine generalCommandLine(@NotNull String workingDirectory, @NotNull Project project, @Nullable Module module, @NotNull List<String> parameters) throws MissingSdk { Sdk sdk; if (module != null) { sdk = mostSpecificSdk(module); } else { sdk = mostSpecificSdk(project); } if (sdk == null) { throw new MissingSdk(project, module); } GeneralCommandLine commandLine = Mix.commandLine( emptyMap(), workingDirectory, sdk, emptyList(), emptyList() ); commandLine.addParameters(parameters); return commandLine; }
@NotNull public GeneralCommandLine createCommandLine() throws ExecutionException { if (myGoRoot == null) { throw new ExecutionException("Sdk is not set or Sdk home path is empty for module"); } GeneralCommandLine commandLine = !myPtyDisabled && PtyCommandLine.isEnabled() ? new PtyCommandLine() : new GeneralCommandLine(); commandLine.setExePath(ObjectUtils.notNull(myExePath, GoSdkService.getGoExecutablePath(myGoRoot))); commandLine.getEnvironment().putAll(myExtraEnvironment); commandLine.getEnvironment().put(GoConstants.GO_ROOT, StringUtil.notNullize(myGoRoot)); commandLine.getEnvironment().put(GoConstants.GO_PATH, StringUtil.notNullize(myGoPath)); if (myVendoringEnabled != null) { commandLine.getEnvironment().put(GoConstants.GO_VENDORING_EXPERIMENT, myVendoringEnabled ? "1" : "0"); } Collection<String> paths = ContainerUtil.newArrayList(); ContainerUtil.addIfNotNull(paths, StringUtil.nullize(commandLine.getEnvironment().get(GoConstants.PATH), true)); ContainerUtil.addIfNotNull(paths, StringUtil.nullize(EnvironmentUtil.getValue(GoConstants.PATH), true)); ContainerUtil.addIfNotNull(paths, StringUtil.nullize(myEnvPath, true)); commandLine.getEnvironment().put(GoConstants.PATH, StringUtil.join(paths, File.pathSeparator)); commandLine.withWorkDirectory(myWorkDirectory); commandLine.addParameters(myParameterList.getList()); commandLine.withParentEnvironmentType(myParentEnvironmentType); commandLine.withCharset(CharsetToolkit.UTF8_CHARSET); return commandLine; }
); generalCommandLine.addParameter(task); generalCommandLine.addParameters(taskParameters);
@NotNull public GeneralCommandLine createCommandLine() throws ExecutionException { GeneralCommandLine commandLine = !myPtyDisabled && PtyCommandLine.isEnabled() ? new PtyCommandLine() : new GeneralCommandLine(); commandLine.setExePath(ObjectUtils.notNull(myExePath, ObjectUtils.notNull(BallerinaSdkService .getBallerinaExecutablePath(myBallerinaPath)))); commandLine.getEnvironment().putAll(myExtraEnvironment); //Todo - Add BALLERINA_REPOSITORY // commandLine.getEnvironment().put(BallerinaConstants.BALLERINA_REPOSITORY, // StringUtil.notNullize(myBallerinaPath)); Collection<String> paths = ContainerUtil.newArrayList(); ContainerUtil.addIfNotNull(paths, StringUtil.nullize(commandLine.getEnvironment().get( BallerinaConstants.PATH), true)); ContainerUtil.addIfNotNull(paths, StringUtil.nullize(EnvironmentUtil.getValue(BallerinaConstants.PATH), true)); ContainerUtil.addIfNotNull(paths, StringUtil.nullize(myEnvPath, true)); commandLine.getEnvironment().put(BallerinaConstants.PATH, StringUtil.join(paths, File.pathSeparator)); commandLine.withWorkDirectory(myWorkDirectory); commandLine.addParameters(myParameterList.getList()); commandLine.withParentEnvironmentType(myParentEnvironmentType); commandLine.withCharset(CharsetToolkit.UTF8_CHARSET); return commandLine; }
private GeneralCommandLine overwriteSomeParametersIfNeeded(GeneralCommandLine commandLine) { String shellWorkingDir = mongoRunConfiguration.getShellWorkingDir(); if (StringUtils.isNotEmpty(shellWorkingDir)) { commandLine.setWorkDirectory(shellWorkingDir); } String shellParameters = mongoRunConfiguration.getShellParameters(); if (StringUtils.isNotEmpty(shellWorkingDir)) { commandLine.addParameters(shellParameters.split(" ")); } return commandLine; } }
commandLine.addParameters(shellArgumentsLine.split(" "));
@Nullable public static String readCommandLine(@Nullable final String workingDirectory, @NotNull final String command, @NotNull final String[] params, @Nullable final String input) { final GeneralCommandLine commandLine = new GeneralCommandLine(command); if (workingDirectory != null) { commandLine.setWorkDirectory(workingDirectory); } commandLine.addParameters(params); return readCommandLine(commandLine, input); }
@NotNull private GeneralCommandLine createCommandLine() { GeneralCommandLine ret = new GeneralCommandLine(); if (SystemInfo.isWindows) { ret.setExePath(ExecUtil.getWindowsShellName()); ret.addParameters("/c", GeneralCommandLine.inescapableQuote(loginSsoCmd)); } else if (SystemInfo.isMac) { ret.setExePath(ExecUtil.getOpenCommandPath()); ret.addParameters("-a", loginSsoCmd); } else { ret.setExePath("/bin/sh"); ret.addParameters("-c", loginSsoCmd); } return ret; } }
GeneralCommandLine commandLine = new GeneralCommandLine(); commandLine.setExePath(javaPath); commandLine.addParameters("-Dfile.encoding=UTF-8", "-Dapple.awt.UIElement=true"); commandLine.addParameters("-jar", monkeybrainsJarPath); commandLine.addParameters(parameters);
public GeneralCommandLine getExecutableCommandLine(final DlangRunAppConfiguration config) throws ModuleNotFoundException, NoValidDlangSdkFound { final Module module = config.getConfigurationModule().getModule(); if (module == null) { throw new ModuleNotFoundException(); } final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module); final Sdk sdk = moduleRootManager.getSdk(); if (sdk == null || !(sdk.getSdkType() instanceof DlangSdkType)) { throw new NoValidDlangSdkFound(); } final VirtualFile sourcesRoot = getSourceRoot(module); final GeneralCommandLine cmd = new GeneralCommandLine(); cmd.setExePath(getOutputFilePath(module)); if (StringUtil.isNotEmpty(config.getWorkDir())) { cmd.withWorkDirectory(config.getWorkDir()); } else { cmd.withWorkDirectory(sourcesRoot.getPath()); } if (StringUtil.isNotEmpty(config.getAdditionalParams())) { cmd.addParameters(splitArguments(config.getAdditionalParams())); } return cmd; }
protected GeneralCommandLine createRunInSimulatorCmd() throws ExecutionException { MonkeyParameters monkeyParameters = getMonkeyParameters(); VirtualFile child = monkeyParameters.getOutputPath().findChild(getPrgName()); if (child == null) { throw new ExecutionException("No .prg file was built, so nothing to run, searched path was " + monkeyParameters.getOutputPath() + " and prg name " + getPrgName()); } String prgPath = child.getPath(); Sdk sdk = monkeyParameters.getSdk(); String sdkBinPath = MonkeySdkType.getBinPath(sdk); String monkeydoExecutableName = SdkHelper.get(SdkHelper.MONKEYDO_CMD); String exePath = sdkBinPath + monkeydoExecutableName; GeneralCommandLine generalCommandLine = createGeneralCommandLine(sdkBinPath, exePath) .withParameters(prgPath, getConfiguration().getTargetDeviceId()); if (isForTests()) { generalCommandLine.addParameter(SdkHelper.get(SdkHelper.MONKEYDO_TEST_PARAM)); //if (testId != null) { // generalCommandLine.addParameter(testId); //} } if (getConfiguration().getProgramParameters() != null) { ParametersList parametersList = new ParametersList(); parametersList.addParametersString(getConfiguration().getProgramParameters()); generalCommandLine.addParameters(parametersList.getParameters()); } return generalCommandLine; }
cmd.addParameters(Arrays.asList(config.getAdditionalParams().split("\\s")));