Context
An 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.
Types
Properties
If true, short options can be grouped after a single -
prefix.
If false, options and arguments cannot be mixed; the first time an argument is encountered, all remaining tokens are parsed as arguments.
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.
The command that this context associated with.
A map holding arbitrary data on the context.
The callable to call to echo output.
If true, an error was previously encountered while parsing the command line, but parsing is continuing to collect any more errors into a MultiUsageError.
The function to call to exit the process with a status code.
If true, arguments starting with @
will be expanded as argument files. If false, they will be treated as normal arguments.
The help formatter for this command.
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.
If this command has subcommands and one of them was invoked, this is the subcommand that will be run first.
All invoked subcommands, in the order they were invoked.
Localized strings to use for help output and error reporting.
The original command line arguments.
Set this to false to prevent extra messages from being printed automatically. You can still access them at messages inside of CliktCommand.run
.
A block that returns the content of an argument file for a given filename.
A function called by Clikt to get a parameter value from a given environment variable
If false
,the valueSource is searched before environment variables.
A callback called when the command line contains an invalid option or subcommand name. It takes the entered name and a list of all registered names option/subcommand names and filters the list down to values to suggest to the user.
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.
The source that will attempt to read values for options that aren't present on the command line.
Functions
Register a callback to be called when this command and all its subcommands have finished.
Return a list of command names, starting with the topmost command and ending with this Context's command.
Throw a UsageError with the given message
Return a list of command names, starting with the topmost command and ending with this Context's parent.
Register an AutoCloseable to be closed when this command and all its subcommands have finished running.
Register an AutoCloseable to be closed when this command and all its subcommands have finished running.