Commands are the basic building block of command line interfaces in Click. A basic command handles command line parsing and might dispatch more parsing to commands nested below it.
context_settings
parameter.no_args_is_help
parameter.Parameters | |
name | the name of the command to use unless a group overrides it. |
context_settings | an optional dictionary with defaults that are passed to the context object. |
callback | the callback to invoke. This is optional. |
params | the parameters to register with this command. This can
be either Option or Argument objects. |
help | the help string to use for this command. |
epilog | like the help string but it's printed at the end of the help page after everything else. |
short_help | the short help to use for this command. This is shown on the command listing of the parent command. |
add_help_option | by default each command registers a --help option. This can be disabled by this parameter. |
no_args_is_help | this controls what happens if no arguments are provided. This option is disabled by default. If enabled this will add --help as argument if no arguments are passed |
hidden | hide this command from help outputs. |
deprecated | issues a message indicating that the command is deprecated. |
Method | __init__ |
Undocumented |
Method | collect_usage_pieces |
Returns all the pieces that go into the usage line and returns it as a list of strings. |
Method | format_epilog |
Writes the epilog into the formatter if it exists. |
Method | format_help |
Writes the help into the formatter if it exists. |
Method | format_help_text |
Writes the help text to the formatter if it exists. |
Method | format_options |
Writes all the options into the formatter if they exist. |
Method | format_usage |
Writes the usage line into the formatter. |
Method | get_help |
Formats the help into a string and returns it. |
Method | get_help_option |
Returns the help option object. |
Method | get_help_option_names |
Returns the names for the help option. |
Method | get_params |
Undocumented |
Method | get_short_help_str |
Gets short help for the command or makes it by shortening the long help string. |
Method | get_usage |
Formats the usage line into a string and returns it. |
Method | invoke |
Given a context, this invokes the attached callback (if it exists) in the right way. |
Method | make_parser |
Creates the underlying option parser for this command. |
Method | parse_args |
Given a context and a list of arguments this creates the parser and parses the arguments, then modifies the context as necessary. This is automatically invoked by make_context . |
Method | shell_complete |
Return a list of completions for the incomplete value. Looks at the names of options and chained multi-commands. |
Method | to_info_dict |
Gather information that could be useful for a tool generating user-facing documentation. This traverses the entire structure below this command. |
Instance Variable | add_help_option |
Undocumented |
Instance Variable | callback |
Undocumented |
Instance Variable | deprecated |
Undocumented |
Instance Variable | epilog |
Undocumented |
Instance Variable | help |
Undocumented |
Instance Variable | hidden |
Undocumented |
Instance Variable | no_args_is_help |
Undocumented |
Instance Variable | options_metavar |
Undocumented |
Instance Variable | params |
Undocumented |
Instance Variable | short_help |
Undocumented |
Inherited from BaseCommand
:
Method | __call__ |
Alias for main . |
Method | __repr__ |
Undocumented |
Method | _main_shell_completion |
Check if the shell is asking for tab completion, process that, then exit early. Called from main before the program is invoked. |
Method | main |
No summary |
Method | make_context |
This function when given an info name and arguments will kick off the parsing and create a new Context . It does not invoke the actual command callback though. |
Class Variable | allow_extra_args |
Undocumented |
Class Variable | allow_interspersed_args |
Undocumented |
Class Variable | ignore_unknown_options |
Undocumented |
Instance Variable | context_settings |
Undocumented |
Instance Variable | name |
Undocumented |
click.core.BaseCommand.__init__
click.core.MultiCommand
Undocumented
Parameters | |
name:t.Optional[ | Undocumented |
context_settings:t.Optional[ | Undocumented |
callback:t.Optional[ | Undocumented |
params:t.Optional[ | Undocumented |
help:t.Optional[ | Undocumented |
epilog:t.Optional[ | Undocumented |
short_help:t.Optional[ | Undocumented |
options_metavar:t.Optional[ | Undocumented |
add_help_option:bool | Undocumented |
no_args_is_help:bool | Undocumented |
hidden:bool | Undocumented |
deprecated:bool | Undocumented |
click.core.MultiCommand
Parameters | |
ctx:Context | Undocumented |
Returns | |
t.List[ | Undocumented |
Parameters | |
ctx:Context | Undocumented |
formatter:HelpFormatter | Undocumented |
Writes the help into the formatter if it exists.
This is a low-level method called by get_help
.
This calls the following methods:
Parameters | |
ctx:Context | Undocumented |
formatter:HelpFormatter | Undocumented |
Parameters | |
ctx:Context | Undocumented |
formatter:HelpFormatter | Undocumented |
click.core.MultiCommand
Parameters | |
ctx:Context | Undocumented |
formatter:HelpFormatter | Undocumented |
Writes the usage line into the formatter.
This is a low-level method called by get_usage
.
Parameters | |
ctx:Context | Undocumented |
formatter:HelpFormatter | Undocumented |
click.core.BaseCommand.get_help
Formats the help into a string and returns it.
Calls format_help
internally.
Parameters | |
ctx:Context | Undocumented |
Returns | |
str | Undocumented |
Parameters | |
ctx:Context | Undocumented |
Returns | |
t.List[ | Undocumented |
Parameters | |
limit:int | Undocumented |
Returns | |
str | Undocumented |
click.core.BaseCommand.get_usage
Formats the usage line into a string and returns it.
Calls format_usage
internally.
Parameters | |
ctx:Context | Undocumented |
Returns | |
str | Undocumented |
click.core.BaseCommand.invoke
click.core.MultiCommand
Parameters | |
ctx:Context | Undocumented |
Returns | |
t.Any | Undocumented |
Parameters | |
ctx:Context | Undocumented |
Returns | |
OptionParser | Undocumented |
click.core.BaseCommand.parse_args
click.core.MultiCommand
make_context
.Parameters | |
ctx:Context | Undocumented |
args:t.List[ | Undocumented |
Returns | |
t.List[ | Undocumented |
click.core.BaseCommand.shell_complete
click.core.MultiCommand
Return a list of completions for the incomplete value. Looks at the names of options and chained multi-commands.
Parameters | |
ctx:Context | Invocation context for this command. |
incomplete:str | Value being completed. May be empty. |
Returns | |
t.List[ | Undocumented |
click.core.BaseCommand.to_info_dict
click.core.MultiCommand
Gather information that could be useful for a tool generating user-facing documentation. This traverses the entire structure below this command.
Use click.Context.to_info_dict
to traverse the entire
CLI structure.
Parameters | |
ctx:Context | A Context representing this command. |
Returns | |
t.Dict[ | Undocumented |