@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 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; }
@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; }
@NotNull @Override public PerlCommandLine withWorkDirectory(@Nullable File workDirectory) { return (PerlCommandLine)super.withWorkDirectory(workDirectory); }
@NotNull @Override public PerlCommandLine withWorkDirectory(@Nullable String path) { return (PerlCommandLine)super.withWorkDirectory(path); }
public static GeneralCommandLine createGeneralCommandLine(String workDirectory, String exePath) { if (SystemInfo.isMac) { String macExePath = exePath; List<String> parameters = new ArrayList<>(); // .app files are opened with open command? if (exePath.endsWith(".app")) { macExePath = "open"; parameters.add(exePath); parameters.add("--args"); } return new GeneralCommandLine() .withWorkDirectory(workDirectory) .withExePath(macExePath) .withParameters(parameters) .withCharset(CharsetToolkit.UTF8_CHARSET); } return new GeneralCommandLine() .withWorkDirectory(workDirectory) .withExePath(exePath) .withCharset(CharsetToolkit.UTF8_CHARSET); } }
@Override protected Process createProcess() throws ExecutionException { String bashLocation = BashInterpreterDetection.instance().findBestLocation(); if (bashLocation == null) { throw new ExecutionException("Could not locate the bash executable"); } GeneralCommandLine commandLine = new GeneralCommandLine().withWorkDirectory(getWorkingDir()); commandLine.setExePath(bashLocation); return commandLine.createProcess(); }
.withWorkDirectory(config.getProject().getBasePath()) .withCharset(Charset.defaultCharset()) .withExePath(dmdPath)
private Optional<DubProject> parseDubConfiguration(final boolean silentMode) { try { final GeneralCommandLine cmd = new GeneralCommandLine() .withWorkDirectory(project.getBaseDir().getCanonicalPath()) .withExePath(dubBinaryPath) .withParameters("describe");
.withWorkDirectory(workingDirectory) .withExePath(this.dubBinary) .withParameters(parametersList.getParameters());
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; }
@NotNull private String processFile(final PsiFile file, final String dubPath) { final GeneralCommandLine cmd = new GeneralCommandLine() .withWorkDirectory(file.getProject().getBasePath()) .withExePath(dubPath) .withEnvironment("DFLAGS", "-o-") .withParameters("build", "--combined", "-q"); try { final String dubCommand = cmd.getCommandLineString(); final DubProcessListener listener = new DubProcessListener(); final OSProcessHandler process = new OSProcessHandler(cmd.createProcess(), dubCommand); process.addProcessListener(listener); process.startNotify(); process.waitFor(); return listener.getOutput(); } catch (final ExecutionException e) { LOG.warn("There was a problem running 'dub build --combined -q'", e); } return ""; }
@NotNull public static GeneralCommandLine createCommandLine(String workingDir, BashRunConfiguration runConfig) { String interpreterPath; if (runConfig.isUseProjectInterpreter()) { interpreterPath = BashProjectSettings.storedSettings(runConfig.getProject()).getProjectInterpreter(); } else { interpreterPath = runConfig.getInterpreterPath(); } GeneralCommandLine cmd = new GeneralCommandLine(); cmd.setExePath(interpreterPath); cmd.getParametersList().addParametersString(runConfig.getInterpreterOptions()); cmd.addParameter(runConfig.getScriptName()); cmd.getParametersList().addParametersString(runConfig.getProgramParameters()); cmd.withWorkDirectory(workingDir); cmd.withParentEnvironmentType(runConfig.isPassParentEnvs() ? GeneralCommandLine.ParentEnvironmentType.CONSOLE : GeneralCommandLine.ParentEnvironmentType.NONE); cmd.withEnvironment(runConfig.getEnvs()); return cmd; }
cmd.withWorkDirectory(config.getWorkingDir()); } else { cmd.withWorkDirectory(config.getProject().getBasePath());