Closed sschuberth closed 1 year ago
This is just a proposal @ajalt, not sure whether you like it as it seems to be a breaking change for explicit users of test(arrayOf("-foo", "--bar"), ...)
.
Thanks for the PR.
We can add the vararg version as a separate overload to keep backwards compatibility:
@JvmName("varargTest")
fun CliktCommand.test(
vararg argv: String,
stdin: String = "",
envvars: Map<String, String> = emptyMap(),
includeSystemEnvvars: Boolean = false,
ansiLevel: AnsiLevel = AnsiLevel.NONE,
width: Int = 79,
height: Int = 24,
): CliktCommandTestResult {
return test(argv.asList(), stdin, envvars, includeSystemEnvvars, ansiLevel, width, height)
}
A vararg version has the potential to be confusing when called with a single argument (test("-x")
calls the single String
version which tokenizes the input, but test("-x", "-y")
calls the vararg version which doesn't), but I can't think of any situation where the single String
version would break fail on any input that would be valid to the varargs, so it should be fine.
We can add the vararg version as a separate overload to keep backwards compatibility:
Done.
Thanks!
For convenience and to better visualize separate options, allow to write
in addition to
This requires to remove the
test(argv: Array<String>, ...)
overload as that would have the same JVM function signature.