twisted.python._shellcomp
module documentationtwisted.python
View Source
No public APIs are provided by this module. Internal use only.
This module implements dynamic tab-completion for any command that uses twisted.python.usage. Currently, only zsh is supported. Bash support may be added in the future.
Maintainer: Eric P. Mangold - twisted AT teratorn DOT org
In order for zsh completion to take place the shell must be able to find an appropriate "stub" file ("completion function") that invokes this code and displays the results to the user.
The stub used for Twisted commands is in the file
twisted-completion.zsh
, which is also included in the official
Zsh distribution at Completion/Unix/Command/_twisted
. Use this
file as a basis for completion functions for your own commands. You should
only need to change the first line to something like #compdef
mycommand
.
The main public documentation exists in the twisted.python.usage.Options
docstring, the twisted.python.usage.Completions
docstring, and the Options howto.
Function | shellComplete | Perform shell completion. |
Class | SubcommandAction | Undocumented |
Class | ZshBuilder | Constructs zsh code that will complete options for a given usage.Options instance, possibly including a list of subcommand names. |
Class | ZshSubcommandBuilder | Constructs zsh code that will complete options for a given usage.Options instance, and also for a single sub-command. This will only be used in the case where the user is completing options for a specific subcommand. |
Class | ZshArgumentsGenerator | Generate a call to the zsh _arguments completion function based on data in a usage.Options instance |
Function | descrFromDoc | Generate an appropriate description from docstring of the given object |
Function | escape | Shell escape the given string |
Perform shell completion.
A completion function (shell script) is generated for the requested
shell and written to shellCompFile
, typically
stdout
. The result is then eval'd by the shell to produce the
desired completions.
Parameters | config | The twisted.python.usage.Options
instance to generate completions for. (type: twisted.python.usage.Options ) |
cmdName | The name of the command we're generating completions for. In the case of
zsh, this is used to print an appropriate "#compdef $CMD" line at
the top of the output. This is not necessary for the functionality of the
system, but it helps in debugging, since the output we produce is properly
formed and may be saved in a file and used as a stand-alone completion
function. (type: str ) | |
words | The raw command-line words passed to use by the shell stub function.
argv[0] has already been stripped off. (type: list of str ) | |
shellCompFile | The file to write completion data to. (type: file ) |
Generate an appropriate description from docstring of the given object
Shell escape the given string
Implementation borrowed from now-deprecated commands.mkarg() in the stdlib