Infinidat / infi.docopt_completion

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

Bash completion doesn't work with local scripts #11

Open con-f-use opened 8 years ago

con-f-use commented 8 years ago

Problem:

inifi.docopt_completion doesn't work with local scripts. Here is a minimal example:

# In Bash
docopt-completion --manual-bash ./prog.py
source prog.py.sh
./prog.py --ve[TAB][TAB]   # Should give '--version' as completion option, but
# No completion options displayed

Proposed solution:

Might have unwanted side-effects but the fastest solution might be to change the FILE_TEMPLATE in bash.py : line 3 to:

FILE_TEMPLATE = """{0}\ncomplete -F _{1} {2}\ncomplete -F _{1} ./{2}"""
wiggin15 commented 8 years ago

I can't reproduce this on Ubuntu 14.04 (bash-completion 2.1).

~# ./a.py
Usage:
    a.py foo
    a.py bar
    a.py --help
    a.py --version
~# docopt-completion ./a.py --manual-bash
Completion file written to ./a.py.sh
~# source ./a.py.sh
~# a.py<tab><tab>
foo        --help     bar       --version
~# ./a.py<tab><tab>
foo        --help     bar       --version
~# foo/a.py<tab><tab>
foo        --help     bar       --version
~# ./a.py --ver<tab><tab>sion