Skip to content

[Feature request] Autocomplete #2

Description

@con-f-use

The thing that gets me about docopt is that there is nothing like argcomplete for argparse. I know one can use docopt_wordlist and docopt-wordlist.bash from docopt.rs but that is hard to set up and doesn't work in some cases. Another solution is infi.docopt_autocomplete that creates bash and zsh completion files. The drawback with that: the user has to update the completion files by hand, EVERY time, the options change in the original script. I think a command line interface goes hand in hand with auto-completion. So if you feel, you're being bored, a nice mechanism for auto-completing commands would be good that doesn't require installation beyond a simple pip install. (See Issue discussed in docopt repository for reference).

Desired result:

If I have and the desired feature "docpie auto-completion" installed:

# This is 'prog.py'
"""
Usage:
    prog.py --long-option --longer-option <file>...
"""
from docpie import docpie
args = docpie(__doc__ % locals()
print args

And prog.py is in the current working directory of my shell together with these other files: example1.txt, example2.txt, example3.txt

I want to be able to auto-complete in the shell like this:

shell> ./prog.py --lo[TAB]
--long-option     --longer-option
shell> ./prog.py --longer[TAB]
shell> ./prog.py --longer-option
shell> ./prog.py --longer-option ex[TAB]
example1.txt   example2.txt    example3.txt

Ideally the auto-completion is smart and uses existing built-in completions for things like files, hostnames, ip-adresses, kernel-versions and s.o. In Bash they can be listed with complete -p.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions