Imported Upstream version 12.1.0
[contrib/python-twisted.git] / twisted / python / zsh / _tapconvert
1 #compdef tapconvert
2 # This file is deprecated. See README.
3
4 # This is the ZSH completion file for Twisted commands. It calls the current
5 # command-line with the special "--_shell-completion" option which is handled
6 # by twisted.python.usage. t.p.usage then generates zsh code on stdout to
7 # handle the completions for this particular command-line.
8 #
9 # 3rd parties that wish to provide zsh completion for commands that
10 # use t.p.usage may copy this file and change the first line to reference
11 # the name(s) of their command(s).
12 #
13 # This file is included in the official Zsh distribution as
14 # Completion/Unix/Command/_twisted
15
16 # redirect stderr to /dev/null otherwise deprecation warnings may get puked
17 # all over the user's terminal if completing options for mktap or other
18 # deprecated commands. Redirect stderr to a file to debug errors.
19 local cmd output
20 cmd=("$words[@]" --_shell-completion zsh:$CURRENT)
21 output=$("$cmd[@]" 2>/dev/null)
22
23 if [[ $output == "#compdef "* ]]; then
24     # Looks like we got a valid completion function - so eval it to produce
25     # the completion matches.
26     eval $output
27 else
28     echo "\nCompletion error running command:" ${(qqq)cmd}
29     echo -n "If output below is unhelpful you may need to edit this file and "
30     echo    "redirect stderr to a file."
31     echo "Expected completion function, but instead got:" 
32     echo $output
33     return 1
34 fi