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

Support for CLI command completions #693

Merged
merged 15 commits into from
Apr 25, 2023
Merged

Conversation

juhoinkinen
Copy link
Member

Adds support for tab-key completions for commands, options and project id and vocabulary id parameters via Click mechanism.

A user needs to enable the support as instructed in README.md, i.e. by sourcing the completion script, either manually for every terminal session or automatically for all new sessions by the sourcing the script in a shell startup file (instructed to use .bashrc).

To produce the completion script the annif completion CLI command is added. This seems to be the standard way that many CLI tools use: pip, dvc, helm.

Implements #684.

@juhoinkinen juhoinkinen added this to the 1.0 milestone Apr 19, 2023
@codecov
Copy link

codecov bot commented Apr 19, 2023

Codecov Report

Patch coverage: 98.48% and project coverage change: +0.01 🎉

Comparison is base (c6daf56) 99.61% compared to head (35bc222) 99.63%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #693      +/-   ##
==========================================
+ Coverage   99.61%   99.63%   +0.01%     
==========================================
  Files          89       89              
  Lines        6166     6222      +56     
==========================================
+ Hits         6142     6199      +57     
+ Misses         24       23       -1     
Impacted Files Coverage Δ
annif/cli_util.py 98.87% <90.90%> (-1.13%) ⬇️
annif/cli.py 99.64% <100.00%> (+0.01%) ⬆️
tests/test_cli.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

annif/cli.py Outdated Show resolved Hide resolved
annif/cli.py Outdated Show resolved Hide resolved
annif/cli_util.py Fixed Show fixed Hide fixed
Tryin to please code quality checkers
Increase test coverage and more check outputs
@juhoinkinen
Copy link
Member Author

The completion response is not very instantaneous but quite usable. On my laptop annif --help and annif --version take 0.6-0.7 s, but I think the completion response is a bit faster.

I tried to optimize startup speed by moving some import statements into functions in cli.py and elsewhere. This cut annif --version time in half but did not affect annif --help and seemed not to affect completion response time. :(

@juhoinkinen juhoinkinen marked this pull request as ready for review April 20, 2023 09:34
@sonarcloud
Copy link

sonarcloud bot commented Apr 25, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@juhoinkinen juhoinkinen merged commit 3451bd3 into main Apr 25, 2023
11 of 12 checks passed
@juhoinkinen juhoinkinen deleted the issue684-cli-command-completions branch April 25, 2023 07:47
@juhoinkinen
Copy link
Member Author

The completion response is not very instantaneous but quite usable. On my laptop annif --help and annif --version take 0.6-0.7 s, but I think the completion response is a bit faster.

I tried to optimize startup speed by moving some import statements into functions in cli.py and elsewhere. This cut annif --version time in half but did not affect annif --help and seemed not to affect completion response time. :(

The response time of completions will be improved by #696 to ~0.3 seconds or slightly less.

@juhoinkinen juhoinkinen linked an issue Apr 26, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI command completions
2 participants