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

Add shell completion for nf-core tools commands #2070

Merged
merged 6 commits into from
Dec 1, 2022

Conversation

mashehu
Copy link
Contributor

@mashehu mashehu commented Nov 29, 2022

Based on the autogenerated scripts from click (https://click.palletsprojects.com/en/8.1.x/shell-completion/).

Unfortunately, I can't use them straight forward (which would also make it a lot easier to integrate them as a normal user), because it would always print the header in between completions. That's why I had to move the print statement of the header into run_nf_core to disable it via a parameter.
If somebody has a better idea how to do suppress the header, I would be grateful!

Thanks to @ewels it is now as simple as adding one line to the one line to the shell configs. It is still not the fastest, but because it calls the program every time, if we make that faster, the completion would also be faster.

@codecov
Copy link

codecov bot commented Nov 29, 2022

Codecov Report

Merging #2070 (38b222f) into dev (57c3c1e) will increase coverage by 0.13%.
The diff coverage is 85.71%.

@@            Coverage Diff             @@
##              dev    #2070      +/-   ##
==========================================
+ Coverage   67.70%   67.84%   +0.13%     
==========================================
  Files          43       43              
  Lines        5555     5588      +33     
==========================================
+ Hits         3761     3791      +30     
- Misses       1794     1797       +3     
Impacted Files Coverage Δ
nf_core/__main__.py 58.52% <85.71%> (+0.06%) ⬆️
nf_core/components/install.py 86.95% <0.00%> (-0.73%) ⬇️
nf_core/components/update.py 81.51% <0.00%> (-0.21%) ⬇️
nf_core/lint_utils.py 85.71% <0.00%> (+12.03%) ⬆️

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

@mashehu
Copy link
Contributor Author

mashehu commented Nov 30, 2022

@nf-core-bot fix linting

Copy link
Member

@mirpedrol mirpedrol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was finally able to use it!! It's a really nice feature 😊

My problem was related to the function that zsh uses to load auto-completions. I solved it adding what this issue suggested to my .zshrc

autoload -Uz compinit
compinit

@mashehu mashehu merged commit 2c8efb1 into nf-core:dev Dec 1, 2022
@mashehu mashehu deleted the add-autocompletion branch December 1, 2022 10:44
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

Successfully merging this pull request may close these issues.

3 participants