From 28d9ee89a4bb9f2837f508f8178ff1b44561fc78 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Mon, 14 Sep 2015 18:27:08 +0300 Subject: [PATCH] [platform] couple more convenient methods for GeneralCommandLine --- .../configurations/GeneralCommandLine.java | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/platform/platform-api/src/com/intellij/execution/configurations/GeneralCommandLine.java b/platform/platform-api/src/com/intellij/execution/configurations/GeneralCommandLine.java index 98517848bcc4..fb8e54183d52 100644 --- a/platform/platform-api/src/com/intellij/execution/configurations/GeneralCommandLine.java +++ b/platform/platform-api/src/com/intellij/execution/configurations/GeneralCommandLine.java @@ -145,6 +145,12 @@ public class GeneralCommandLine implements UserDataHolder { return this; } + @NotNull + public GeneralCommandLine withEnvironment(@NotNull String key, @NotNull String value) { + getEnvironment().put(key, value); + return this; + } + /** @deprecated use {@link #getParentEnvironmentType()} (to be removed in IDEA 17) */ @SuppressWarnings("unused") public boolean isPassParentEnvironment() { @@ -190,15 +196,23 @@ public class GeneralCommandLine implements UserDataHolder { } public void addParameters(String... parameters) { - for (String parameter : parameters) { - addParameter(parameter); - } + withParameters(parameters); } public void addParameters(@NotNull List parameters) { - for (String parameter : parameters) { - addParameter(parameter); - } + withParameters(parameters); + } + + @NotNull + public GeneralCommandLine withParameters(@NotNull String... parameters) { + for (String parameter : parameters) addParameter(parameter); + return this; + } + + @NotNull + public GeneralCommandLine withParameters(@NotNull List parameters) { + for (String parameter : parameters) addParameter(parameter); + return this; } public void addParameter(@NotNull String parameter) {