Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file/path completion #26

Open
flokno opened this issue Jul 16, 2019 · 3 comments
Open

file/path completion #26

flokno opened this issue Jul 16, 2019 · 3 comments

Comments

@flokno
Copy link

flokno commented Jul 16, 2019

This is a follow up on #6

I think the -f flag in the very end of https://github.com/click-contrib/click-completion/blob/master/click_completion/fish.j2#L1 inhibits file completion in my app.

I think this is related to a change in the behavior of the -f flag in fish itself after Nov. 2017, see this PR: fish-shell/fish-shell#4560

The ninja command here is older. When I remove the -f locally, I see file completion.

@flokno
Copy link
Author

flokno commented Jul 16, 2019

I feel the -f is there to supress file suggestions when one is still fishing for options (with -f removed one sees file suggestions always). Thus I think it should be triggered from the app and not being hard coded to the command.

@flokno
Copy link
Author

flokno commented Jul 16, 2019

I use this fork for now: https://github.com/flokno/click-completion/tree/fish_complete_files

Any comments/suggestions on how to approach this?

@exploide
Copy link

While using pipenv, which makes use of click-completion, I encountered this problem, too. E.g. pipenv install -r should complete files, but doesn't, which is annoying. A related issue was reported there pypa/pipenv#3478

I took a look at the code of click-completion. The -f option mentioned in the first comment is obviously the cause for this. But just removing the -f would imply that unnecessary file arguments get completed when, for example, just subcommands make sense.

So either the stub fish completion template needs to become more complex (don't know yet how to do that in an universal way) or click-completion needs to emit file completions by itself (and stay with the global -f).

It looks like this is done for the zsh completion automatically when there are no other explicit arguments to complete. However, the way this is done seems not to work with fish. So maybe this needs indeed to be done with an additional function. The completions for pip (without click-completion) do something like that: https://github.com/pypa/pip/blob/69a811cec64d16f4a3c84f685c50ac319f938772/src/pip/_internal/cli/autocompletion.py#L136

Instead of doing this when there are no other explicit arguments, it could be reasonable to check if the to be completed option is a click file argument https://click.palletsprojects.com/en/master/arguments/#file-arguments (though, I have no experience with click).

Would be great if this can eventually be resolved somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants