kommand
kommand copied to clipboard
Add support for varargs command arguments
Given the nature of command arguments, it would be great if the API supported varargs.
Currently I'm supplementing the API with:
fun Command.args(vararg args: String) = args(args.toList())
Ideally rather than doing this:
Command("ping")
.args(listOf("-c", "5", "localhost"))
One should be able to do this:
Command("ping")
.args("-c", "5", "localhost")
The advantage of varargs is that it allows to also do fancy things with spread, such as:
Command("ping")
.args(getPingCount()*, "localhost")
fun getPingCount(): Array<String> =
if(config.pingCount >= 1) arrayOf("-c", config.pingCount.toString()) else emptyArray()
It will be added in subsequent versions, within one month
Now supports