class Context
A object used to control command line parsing and pass data between commands.
A new Context instance is created for each command each time the command line is parsed.
class Builder |
Context(parent: Context?, command: CliktCommand, allowInterspersedArgs: Boolean, autoEnvvarPrefix: String?, helpOptionNames: Set<String>, helpOptionMessage: String, helpFormatter: HelpFormatter, tokenTransformer: Context.(String) -> String)
A object used to control command line parsing and pass data between commands. |
val allowInterspersedArgs: Boolean
If false, options and arguments cannot be mixed; the first time an argument is encountered, all remaining tokens are parsed as arguments. |
|
val autoEnvvarPrefix: String?
The prefix to add to inferred envvar names. If null, the prefix is based on the parent's prefix, if there is one. If no command specifies, a prefix, envvar lookup is disabled. |
|
val command: CliktCommand
The command that this context associated with. |
|
val helpFormatter: HelpFormatter
The help formatter for this command |
|
val helpOptionMessage: String
The description of the help option. |
|
val helpOptionNames: Set<String>
The names to use for the help option. If any names in the set conflict with other options, the conflicting name will not be used for the help option. If the set is empty, or contains no unique names, no help option will be added. |
|
var invokedSubcommand: CliktCommand? |
|
var obj: Any? |
|
val parent: Context?
If this context is the child of another command, parent is the parent command's context. |
|
val tokenTransformer: Context.(String) -> String
An optional transformation function that is called to transform command line tokens (options and commands) before parsing. This can be used to implement e.g. case insensitive behavior. |
fun fail(message: String = ""): Nothing
Throw a UsageError with the given message |
|
fun <T> findObject(): T?
Find the closest object of type T fun <T> findObject(defaultValue: () -> T): T
Find the closest object of type T, setting |
|
fun findRoot(): Context
Find the outermost context |
fun build(command: CliktCommand, parent: Context? = null, block: Builder.() -> Unit): Context |