Add warning to 'kotlinc.bat help' that delimiters need to be escaped
Related to KT-41303, KT-41309.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.cli.common;
|
||||
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import kotlin.jvm.JvmClassMappingKt;
|
||||
import kotlin.reflect.KCallable;
|
||||
@@ -29,6 +30,9 @@ import org.jetbrains.kotlin.cli.common.arguments.ParseCommandLineArgumentsKt;
|
||||
import org.jetbrains.kotlin.cli.common.arguments.PreprocessCommandLineArgumentsKt;
|
||||
|
||||
public class Usage {
|
||||
public static final String BAT_DELIMITER_CHARACTERS_NOTE =
|
||||
"Note: on Windows, arguments that contain delimiter characters (whitespace, =, ;, ,) need to be surrounded with double quotes (\").";
|
||||
|
||||
// The magic number 29 corresponds to the similar padding width in javac and scalac command line compilers
|
||||
private static final int OPTION_NAME_PADDING_WIDTH = 29;
|
||||
|
||||
@@ -41,7 +45,7 @@ public class Usage {
|
||||
KClass<? extends CommonToolArguments> kClass = JvmClassMappingKt.getKotlinClass(arguments.getClass());
|
||||
for (KCallable<?> callable : kClass.getMembers()) {
|
||||
if (!(callable instanceof KProperty1)) continue;
|
||||
propertyUsage(sb, (KProperty1) callable, extraHelp);
|
||||
propertyUsage(sb, (KProperty1<?, ?>) callable, extraHelp);
|
||||
}
|
||||
|
||||
if (extraHelp) {
|
||||
@@ -52,10 +56,15 @@ public class Usage {
|
||||
renderArgfileUsage(sb);
|
||||
}
|
||||
|
||||
if (SystemInfo.isWindows) {
|
||||
appendln(sb, "");
|
||||
appendln(sb, BAT_DELIMITER_CHARACTERS_NOTE);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static void propertyUsage(@NotNull StringBuilder sb, @NotNull KProperty1 property, boolean extraHelp) {
|
||||
private static void propertyUsage(@NotNull StringBuilder sb, @NotNull KProperty1<?, ?> property, boolean extraHelp) {
|
||||
Argument argument = ContainerUtil.findInstance(property.getAnnotations(), Argument.class);
|
||||
if (argument == null) return;
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.checkers.AbstractForeignAnnotationsTestKt;
|
||||
import org.jetbrains.kotlin.cli.common.CLITool;
|
||||
import org.jetbrains.kotlin.cli.common.ExitCode;
|
||||
import org.jetbrains.kotlin.cli.common.Usage;
|
||||
import org.jetbrains.kotlin.cli.js.K2JSCompiler;
|
||||
import org.jetbrains.kotlin.cli.js.dce.K2JSDce;
|
||||
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler;
|
||||
@@ -85,6 +86,7 @@ public abstract class AbstractCliTest extends TestCaseWithTmpdir {
|
||||
.replace("expected version is " + JsMetadataVersion.INSTANCE, "expected version is $ABI_VERSION$")
|
||||
.replace("\\", "/")
|
||||
.replace(KotlinCompilerVersion.VERSION, "$VERSION$")
|
||||
.replace("\n" + Usage.BAT_DELIMITER_CHARACTERS_NOTE + "\n", "")
|
||||
.replaceAll("log4j:WARN.*\n", "");
|
||||
|
||||
return normalizedOutputWithoutExitCode + exitCode + "\n";
|
||||
|
||||
Reference in New Issue
Block a user