Infinidat / infi.docopt_completion

BSD 3-Clause "New" or "Revised" License
109 stars 9 forks source link

docopt-completion example.py doesn't work #2

Closed Honghe closed 10 years ago

Honghe commented 10 years ago

env:

docopt_example.py file:

#!/usr/bin//env python
# coding: utf-8

"""Usage:
 docopt_example.py tcp <host> <port> [--timeout=<seconds>]
 docopt_example.py serial <port> [--baud=9600] [--timeout=<seconds>]
 docopt_example.py -h | --help | --version

"""
from docopt import docopt

if __name__ == '__main__':
 arguments = docopt(__doc__, version='0.1.1rc')
 print arguments

Test on following command, but it doesn't work:

sudo pip install docopt-completion
sudo docopt-completion ./docopt_example.py  
Completion file written to /etc/bash_completion.d/docopt_example.py.sh

And then follow @wiggin15 suggestion to change the name from ocopt_example.py to docopt_example, but find that there is mix up on auto-completetion: This docstring is:

Usage:
    docopt_example.py tcp <host> <port> [--timeout=<seconds>]
    docopt_example.py serial <port> [--baud=9600] [--timeout=<seconds>]
    docopt_example.py -h | --help | --version

but the auto-completion prompt is:

./docopt_example.py 
-h               --help           tcp              --versionserial 
wiggin15 commented 10 years ago

Thanks for the feedback. I uploaded a new version to pypi with fixes to the two problems you reported. Please confirm it works now.

Honghe commented 10 years ago

@wiggin15 sorry, how to pip install the not normal version infi.docopt_completion 0.1.5.post4.g32ecf43 on line?

wiggin15 commented 10 years ago

Use pip install --upgrade --pre infi.docopt_completion (or use easy_install -U infi.docopt_completion)

Honghe commented 10 years ago

@wiggin15 OK, it works. Sorry for another question: Where does completion file store? It seems at /etc/bash_completion.d/, is it? And how to remove the completion file of a specified Python scripts? It seems sometime I can't overwrite the completion file when Python scripts is modified. Thanks!

wiggin15 commented 10 years ago

Yes, that's the correct path. docopt-completion outputs the path to the generated file. You should be able to remove or overwrite the file, if you use sudo, I can't think of a reason why it won't work.