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

CLI command completions #684

Closed
juhoinkinen opened this issue Mar 20, 2023 · 2 comments · Fixed by #693
Closed

CLI command completions #684

juhoinkinen opened this issue Mar 20, 2023 · 2 comments · Fixed by #693
Milestone

Comments

@juhoinkinen
Copy link
Member

juhoinkinen commented Mar 20, 2023

Click provides support for tab completion in different shells. In the case of Annif, Click documentation instructs to use this to register the autocompletion function (and to add it to ~/.bashrc):

eval "$(_ANNIF_COMPLETE=bash_source annif)"

We could add this to installation instructions. Or even add an Annif command to generate the function, like in helm CLI.

The completion is a bit laggy but usable. Apparently the cli.py module is run for each tab press, and the imports there take most of the time.

The default completions work for "command names, option names, and values for choice, file, and path parameter types". In the case of Annif it would be nice to have completions also for project-ids, which could be accomplished using a class with shell_complete() method or just a helper function: in either case the method/function would need to read the project ids from the configuration file, but (preferably) not via registry.get_projects() because then imports of backend dependencies would make the completion unnecessarily slow.

@osma
Copy link
Member

osma commented Mar 21, 2023

Sounds good, and this is another reason why optimizing startup performance is important (which generally means using lazy imports of some kind). Some of this has already been done (#514, #544, #563) but I think another round of optimization should be done after the refactoring in #681.

@juhoinkinen juhoinkinen added this to the 1.0 milestone Apr 26, 2023
@juhoinkinen juhoinkinen linked a pull request Apr 26, 2023 that will close this issue
@juhoinkinen
Copy link
Member Author

Closed by the linked issue.

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

Successfully merging a pull request may close this issue.

2 participants