public 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.
| Modifier and Type | Class and Description |
|---|---|
static class |
Context.Builder |
static class |
Context.Companion |
| Modifier and Type | Field and Description |
|---|---|
static Context.Companion |
Companion |
| Constructor and Description |
|---|
Context(Context parent,
CliktCommand command,
boolean allowInterspersedArgs,
java.lang.String autoEnvvarPrefix,
boolean printExtraMessages,
java.util.Set<java.lang.String> helpOptionNames,
java.lang.String helpOptionMessage,
HelpFormatter helpFormatter,
kotlin.jvm.functions.Function2<? super com.github.ajalt.clikt.core.Context,? super java.lang.String,java.lang.String> tokenTransformer,
CliktConsole console)
A object used to control command line parsing and pass data between commands.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Void |
fail(java.lang.String message)
Throw a
exception UsageError with the given message |
Context |
findRoot()
Find the outermost context
|
boolean |
getAllowInterspersedArgs()
If false,
|
java.lang.String |
getAutoEnvvarPrefix()
The prefix to add to inferred envvar names.
|
CliktCommand |
getCommand()
The command that this context associated with.
|
CliktConsole |
getConsole()
The console to use to print messages.
|
HelpFormatter |
getHelpFormatter()
The help formatter for this command.
|
java.lang.String |
getHelpOptionMessage()
The description of the help option.
|
java.util.Set<java.lang.String> |
getHelpOptionNames()
The names to use for the help option.
|
CliktCommand |
getInvokedSubcommand() |
java.lang.Object |
getObj() |
Context |
getParent()
If this context is the child of another command,
|
boolean |
getPrintExtraMessages()
Set this to false to prevent extra messages from being printed automatically.
|
kotlin.jvm.functions.Function2<com.github.ajalt.clikt.core.Context,java.lang.String,java.lang.String> |
getTokenTransformer()
An optional transformation function that is called to transform command line
|
void |
setInvokedSubcommand$module(CliktCommand p) |
void |
setObj(java.lang.Object p) |
public static Context.Companion Companion
public Context(@Nullable
Context parent,
@NotNull
CliktCommand command,
boolean allowInterspersedArgs,
@Nullable
java.lang.String autoEnvvarPrefix,
boolean printExtraMessages,
@NotNull
java.util.Set<java.lang.String> helpOptionNames,
@NotNull
java.lang.String helpOptionMessage,
@NotNull
HelpFormatter helpFormatter,
@NotNull
kotlin.jvm.functions.Function2<? super com.github.ajalt.clikt.core.Context,? super java.lang.String,java.lang.String> tokenTransformer,
@NotNull
CliktConsole console)
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.
parent - If this context is the child of another command, parent is the parent command's context.command - The command that this context associated with.allowInterspersedArgs - If false, options and arguments cannot be mixed; the first time an argument isencountered, all remaining tokens are parsed as arguments.autoEnvvarPrefix - The prefix to add to inferred envvar names. If null, the prefix is based on theparent's prefix, if there is one. If no command specifies, a prefix, envvar lookup is disabled.printExtraMessages - Set this to false to prevent extra messages from being printed automatically.You can still access them at CliktCommand.messages inside of CliktCommand.run.helpOptionNames - The names to use for the help option. If any names in the set conflict with otheroptions, the conflicting name will not be used for the help option. If the set is empty, or contains nounique names, no help option will be added.helpOptionMessage - The description of the help option.helpFormatter - The help formatter for this command.tokenTransformer - An optional transformation function that is called to transform command linetokens (options and commands) before parsing. This can be used to implement e.g. case insensitivebehavior.console - The console to use to print messages.@Nullable public CliktCommand getInvokedSubcommand()
public void setInvokedSubcommand$module(@Nullable
CliktCommand p)
@Nullable public java.lang.Object getObj()
public void setObj(@Nullable
java.lang.Object p)
@NotNull public Context findRoot()
Find the outermost context
@NotNull
public java.lang.Void fail(@NotNull
java.lang.String message)
Throw a exception UsageError with the given message
exception UsageError@Nullable public Context getParent()
If this context is the child of another command,
parent is the parent command's context.
@NotNull public CliktCommand getCommand()
The command that this context associated with.
public boolean getAllowInterspersedArgs()
If false,
options and arguments cannot be mixed; the first time an argument isencountered, all remaining tokens are parsed as arguments.
@Nullable public java.lang.String getAutoEnvvarPrefix()
The prefix to add to inferred envvar names.
If null, the prefix is based on theparent's prefix, if there is one. If no command specifies, a prefix, envvar lookup is disabled.
public boolean getPrintExtraMessages()
Set this to false to prevent extra messages from being printed automatically.
You can still access them at CliktCommand.messages inside of CliktCommand.run.
CliktCommand.messages,
CliktCommand.run@NotNull public java.util.Set<java.lang.String> getHelpOptionNames()
The names to use for the help option.
If any names in the set conflict with otheroptions, the conflicting name will not be used for the help option. If the set is empty, or contains nounique names, no help option will be added.
@NotNull public java.lang.String getHelpOptionMessage()
The description of the help option.
@NotNull public HelpFormatter getHelpFormatter()
The help formatter for this command.
@NotNull public kotlin.jvm.functions.Function2<com.github.ajalt.clikt.core.Context,java.lang.String,java.lang.String> getTokenTransformer()
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 insensitivebehavior.
@NotNull public CliktConsole getConsole()
The console to use to print messages.