diff --git a/clikt/src/main/kotlin/com/github/ajalt/clikt/core/CliktCommand.kt b/clikt/src/main/kotlin/com/github/ajalt/clikt/core/CliktCommand.kt index 2ea5a5b1f..970855c31 100755 --- a/clikt/src/main/kotlin/com/github/ajalt/clikt/core/CliktCommand.kt +++ b/clikt/src/main/kotlin/com/github/ajalt/clikt/core/CliktCommand.kt @@ -132,18 +132,22 @@ abstract class CliktCommand constructor( * * You should use [main] instead unless you want to handle output yourself. */ - fun parse(argv: Array, context: Context? = null) { - createContext(context) + fun parse(argv: List, parentContext: Context? = null) { + createContext(parentContext) Parser.parse(argv, this.context) } + fun parse(argv: Array, parentContext: Context? = null) { + parse(argv.asList(), parentContext) + } + /** * Parse the command line and print helpful output if any errors occur. * * This function calls [parse] and catches and [CliktError]s that are thrown. Other error are allowed to * pass through. */ - fun main(argv: Array) { + fun main(argv: List) { try { parse(argv) } catch (e: PrintHelpMessage) { @@ -164,6 +168,8 @@ abstract class CliktCommand constructor( } } + fun main(argv: Array) = main(argv.asList()) + /** * Perform actions after parsing is complete and this command is invoked. * diff --git a/clikt/src/main/kotlin/com/github/ajalt/clikt/parsers/Parser.kt b/clikt/src/main/kotlin/com/github/ajalt/clikt/parsers/Parser.kt index f099e8ef9..94e46551f 100755 --- a/clikt/src/main/kotlin/com/github/ajalt/clikt/parsers/Parser.kt +++ b/clikt/src/main/kotlin/com/github/ajalt/clikt/parsers/Parser.kt @@ -9,8 +9,8 @@ import com.github.ajalt.clikt.parsers.OptionParser.Invocation import com.github.ajalt.clikt.parsers.OptionParser.ParseResult internal object Parser { - fun parse(argv: Array, context: Context) { - parse(argv.asList(), context, 0) + fun parse(argv: List, context: Context) { + parse(argv, context, 0) } private tailrec fun parse(argv: List, context: Context, startingArgI: Int) {