TL;DR: We currently don't supporting completing modules invoked with python -m <module>, and we should.
It has been quite difficult to support python scripts and modules at the same time.
The easiest way to support python scripts was to use #compdef -P *.py . This is due to the fact that it allows us to be agnostic to the way the the script is invoked:
If the command line is ./script.py, our script will be executed with words=./script.py.
If the command line is python <flags> script.py, then the completion framework will go through
python's completion script that will trim everything up to the script itself from words, and then our script will be execited with words=script.py.
In short, this makes identifying the actual script easy, and searching for the magic string easy.
In order to add modules to the mix, we need a different compdef line that will allow us to identify the relevant patterns without messing up what we have already established. This is probably possible, but was difficult enough to postpone it to another time.
It might be useful to try and implement this feature as a separate zsh completion script.
TL;DR: We currently don't supporting completing modules invoked with
python -m <module>
, and we should.It has been quite difficult to support python scripts and modules at the same time.
The easiest way to support python scripts was to use
#compdef -P *.py
. This is due to the fact that it allows us to be agnostic to the way the the script is invoked:./script.py
, our script will be executed withwords=./script.py
.python <flags> script.py
, then the completion framework will go through python's completion script that will trim everything up to the script itself from words, and then our script will be execited withwords=script.py
.In short, this makes identifying the actual script easy, and searching for the magic string easy.
In order to add modules to the mix, we need a different
compdef
line that will allow us to identify the relevant patterns without messing up what we have already established. This is probably possible, but was difficult enough to postpone it to another time.It might be useful to try and implement this feature as a separate zsh completion script.