CommandLineParser

Methods for parsing command lines and running commands manually.

Functions

Link copied to clipboard

Finalize a command invocation, converting and setting the values for all options and other parameters. This function does not finalizeEagerOptions or run the command.

Link copied to clipboard

Finalize eager options for a command invocation, running them if they were invoked.

Link copied to clipboard
inline fun <T : BaseCliktCommand<T>> main(command: T, parseAndRun: T.() -> Unit)

Call parseAndRun on the given command. If an error is thrown, exit the process with the error's status code.

Link copied to clipboard
inline fun <T : BaseCliktCommand<T>, R> mainReturningValue(command: T, parseAndRun: T.() -> R): R

Call parseAndRun on the given command. If an error is thrown, exit the process with the error's status code.

Link copied to clipboard

Parse a command line and return the result.

Link copied to clipboard
inline fun <T : BaseCliktCommand<T>> parseAndRun(command: T, argv: List<String>, runCommand: (T) -> Unit): CommandLineParseResult<T>

A shortcut for calling run(parse(command, argv).invocation, runCommand)

Link copied to clipboard
inline fun <T : BaseCliktCommand<T>> run(rootInvocation: CommandInvocation<T>, runCommand: (T) -> Unit)

Finalize and run all invoked commands.

Link copied to clipboard
fun tokenize(commandLine: String, filename: String = "", localization: Localization = defaultLocalization): List<String>

Split a command line into a list of argv tokens.