kommand icon indicating copy to clipboard operation
kommand copied to clipboard

Add support for varargs command arguments

Open ColinHebert opened this issue 1 year ago • 1 comments

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()

ColinHebert avatar Mar 12 '24 21:03 ColinHebert

It will be added in subsequent versions, within one month

BppleMan avatar Mar 13 '24 09:03 BppleMan

Now supports

BppleMan avatar Jul 23 '24 13:07 BppleMan