Closed juhoinkinen closed 1 year ago
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.
Closed by the linked issue.
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
):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 viaregistry.get_projects()
because then imports of backend dependencies would make the completion unnecessarily slow.