click-contrib / click-completion

Add or enhance bash, fish, zsh and powershell completion in Click
MIT License
288 stars 32 forks source link

Default to completing files in Zsh #3

Closed segevfiner closed 6 years ago

segevfiner commented 6 years ago

This is similar to Bash's -o default that is currently used.

glehmann commented 6 years ago

It doesn't seem to change the behavior here. Would you have an example that I can test?

segevfiner commented 6 years ago

It doesn't seem to change the behavior here. Would you have an example that I can test?

Source

#!/usr/bin/env python
import click
import click_completion

click_completion.init()

@click.command()
@click.argument("name-file", type=click.File("r"))
def f(name_file):
    print "Hello, {}!".format(name_file.read())

if __name__ == "__main__":
    f()

On master branch

➜ eval "$(_HELLO_COMPLETE=source-zsh hello)"
➜ hello <tab><tab><tab> # Nothing... sigh...

This PR

➜ eval "$(_HELLO_COMPLETE=source-zsh hello)"
➜ hello <tab>
# File names are suggested

Which is what -o default does in Bash, suggesting file names if no completions are generated.

glehmann commented 6 years ago

ok, works for me too — I just had the wrong version tested…

glehmann commented 6 years ago

thanks!