diff --git a/src/dorkbox/executor/Executor.kt b/src/dorkbox/executor/Executor.kt index 5df8357..38430fc 100644 --- a/src/dorkbox/executor/Executor.kt +++ b/src/dorkbox/executor/Executor.kt @@ -119,9 +119,9 @@ open class Executor { * http://bugs.java.com/view_bug.do?bug_id=7028124 * https://bugs.openjdk.java.net/browse/JDK-6518827 */ - internal fun fixArguments(command: List): List { + internal fun fixArguments(command: Iterable): List { if (!IS_OS_WINDOWS) { - return command + return command.toList() } val result = mutableListOf().apply{ addAll(command) } @@ -357,16 +357,31 @@ open class Executor { } /** - * Add a program (or it's arguments) which are being executed. + * Add arguments to an existing command, which will be executed. * * This does not replace commands, it adds to them * - * @param command A string array containing the program and/or its arguments. + * @param arguments A string array containing the program and/or its arguments. * * @return This process executor. */ - fun addCommand(vararg command: String): Executor { - val fixed = fixArguments(listOf(*command)) + fun addArg(vararg arguments: String): Executor { + val fixed = fixArguments(listOf(*arguments)) + builder.command().addAll(fixed) + return this + } + + /** + * Add arguments to an existing command, which will be executed. + * + * This does not replace commands, it adds to them + * + * @param arguments A string array containing the program and/or its arguments. + * + * @return This process executor. + */ + fun addArg(arguments: Iterable): Executor { + val fixed = fixArguments(arguments) builder.command().addAll(fixed) return this } diff --git a/src/dorkbox/executor/JvmExecOptions.kt b/src/dorkbox/executor/JvmExecOptions.kt index 6907899..d60678e 100644 --- a/src/dorkbox/executor/JvmExecOptions.kt +++ b/src/dorkbox/executor/JvmExecOptions.kt @@ -251,6 +251,34 @@ class JvmExecOptions(private val executor: Executor) { return this } + /** + * Add arguments to an existing command, which will be executed. + * + * This does not replace commands, it adds to them + * + * @param arguments A string array containing the program and/or its arguments. + * + * @return This process executor. + */ + fun addArg(vararg arguments: String): JvmExecOptions { + executor.addArg(*arguments) + return this + } + + /** + * Add arguments to an existing command, which will be executed. + * + * This does not replace commands, it adds to them + * + * @param arguments A string array containing the program and/or its arguments. + * + * @return This process executor. + */ + fun addArg(arguments: Iterable): JvmExecOptions { + executor.addArg(arguments) + return this + } + /** * Executes the JAVA sub process. * diff --git a/src/dorkbox/executor/SshExecOptions.kt b/src/dorkbox/executor/SshExecOptions.kt index 7dd36e3..d94a06a 100644 --- a/src/dorkbox/executor/SshExecOptions.kt +++ b/src/dorkbox/executor/SshExecOptions.kt @@ -172,6 +172,34 @@ class SshExecOptions(val executor: Executor) { return this } + /** + * Add arguments to an existing command, which will be executed. + * + * This does not replace commands, it adds to them + * + * @param arguments A string array containing the program and/or its arguments. + * + * @return This process executor. + */ + fun addArg(vararg arguments: String): SshExecOptions { + executor.addArg(*arguments) + return this + } + + /** + * Add arguments to an existing command, which will be executed. + * + * This does not replace commands, it adds to them + * + * @param arguments A string array containing the program and/or its arguments. + * + * @return This process executor. + */ + fun addArg(arguments: Iterable): SshExecOptions { + executor.addArg(arguments) + return this + } + /** * Executes the JAVA sub process.