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

tab completion during interactive prompts #173

Open
chaoflow opened this issue Jun 26, 2014 · 10 comments
Open

tab completion during interactive prompts #173

chaoflow opened this issue Jun 26, 2014 · 10 comments
Labels
f:completion feature: shell completion f:prompt feature: prompt for input

Comments

@chaoflow
Copy link
Contributor

It would be nice if click would support tab completion when prompting for files and paths.

@untitaker
Copy link
Contributor

The shell command read -e offers a prompt with tab completion. However, the -e flag is a bashism, so we can only use this when bash is installed. I think only offering tab completion when bash is installed is a reasonable tradeoff to make, as any custom tab-completion would require much more code.

@chaoflow
Copy link
Contributor Author

Personally, I'm a zsh user, but given a bash solution I'd figure something.

On the other hand, tab completion shouldn't be too difficult in pure python.

@untitaker
Copy link
Contributor

The solution i proposed only requires it to be installed, not to be used.

@chaoflow
Copy link
Contributor Author

chaoflow commented Jul 1, 2014

Good point. However, read -e is using readline, which is GPL, which I'm not sure whether we can use in click.

Independent of bash vs python, displaying matches feels more complex than gathering the matches.

Would bash's read -e solve that for us?

@untitaker
Copy link
Contributor

It does the whole prompt-thing for us and saves the result in a shell variable. I think i'll try to write a first implementation later this evening. @mitsuhiko Thoughts?

untitaker added a commit to untitaker/click that referenced this issue Jul 1, 2014
See pallets#173. This is not ready for merge yet.

- Missing tests, changelog entry, and isn't yet used in click.Path/File.

- Is a very myopic implementation. Users will ask for custom completion
  functions, which bash's read of course doesn't support.
untitaker added a commit to untitaker/click that referenced this issue Jul 1, 2014
See pallets#173. This is not ready for merge yet.

- Missing tests, changelog entry, and isn't yet used in click.Path/File.

- Is a very myopic implementation. Users will ask for custom completion
  functions, which bash's read of course doesn't support.
@mitsuhiko
Copy link
Contributor

The whole completion support needs rewriting or cleaning up. It absolutely makes no sense currently. It's wrong and mostly works by chance :)

@untitaker
Copy link
Contributor

I don't think the command completion for bash is technically related to this.

@nir0s
Copy link

nir0s commented Jun 28, 2016

Um.. anything on this? I see that there's a PR on this at #428 ... but it's sorta old.

@chaoflow
Copy link
Contributor Author

chaoflow commented Sep 4, 2017

Do we have tab completion for choice option prompts? Does this fit this issues scope after adjusting title and description or shall I open a new issue?

@chaoflow chaoflow changed the title Feature request: Tab completion for prompt of click.Path/File Feature request: Tab completion for prompt of click.Path/File/Choice Feb 10, 2018
@davidism davidism added the f:completion feature: shell completion label Feb 28, 2020
@davidism davidism changed the title Feature request: Tab completion for prompt of click.Path/File/Choice tab completion during interactive prompts Aug 13, 2020
@davidism davidism added the f:prompt feature: prompt for input label Aug 13, 2020
@davidism
Copy link
Member

davidism commented Oct 3, 2020

The completion system has been totally rewritten in #1622. The prompt system can get completions for a parameter by calling param.shell_complete(ctx, incomplete). #181 explored using readline, but that's not guaranteed to be built with Python, and there's an issue around license. It also points out that there are other nice solutions like prompt-toolkit. I'd like to avoid adding optional dependencies, so the first thing that needs to be done is to design a way for prompt to be customized more, so extensions could provide implementations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f:completion feature: shell completion f:prompt feature: prompt for input
Projects
None yet
Development

No branches or pull requests

5 participants