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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
switch to eval initalisation
mashehu committed Nov 29, 2022

Verified

This commit was signed with the committer’s verified signature.
KyleFromNVIDIA Kyle Edwards
commit 58b6e8f7be721e9b5dd4b99fd89a268ceaa88dc9
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -216,7 +216,14 @@ Please refer to the respective documentation for further details to manage packa

### Activate shell completions for nf-core/tools

Auto-completion for the `nf-core` command is available for bash and zsh. To activate it, you have to download the completion scripts (`.nf-core-complete.bash` or `.nf-core-complete.zsh`) and source it in your shell configuration file (`.bashrc` or `.zshrc`).
Auto-completion for the `nf-core` command is available for bash, zsh and fish. To activate it, add the following line to the respective shell config files.
shell | shell config file | command
--- | --- | ---
bash | ~/.bashrc | `eval "$(_NF_CORE_COMPLETE=bash_source nf-core)"`
Zsh | ~/.zshrc | `eval "$(_NF_CORE_COMPLETE=zsh_source nf-core)"`
fish | ~/.config/fish/completions/nf-core.fish | `eval (env _NF_CORE_COMPLETE=fish_source nf-core)`

After a restart of the shell session you should have auto-completion for the `nf-core` command and all its sub-commands and options.

## Listing pipelines

36 changes: 18 additions & 18 deletions nf_core/__main__.py
Original file line number Diff line number Diff line change
@@ -79,24 +79,8 @@


def run_nf_core():
# Launch the click cli
nf_core_cli(auto_envvar_prefix="NFCORE")


@click.group(context_settings=dict(help_option_names=["-h", "--help"]))
@click.version_option(nf_core.__version__)
@click.option("-v", "--verbose", is_flag=True, default=False, help="Print verbose output to the console.")
@click.option("--no-header", is_flag=True, default=False, help="Don't print the header.")
@click.option("--hide-progress", is_flag=True, default=False, help="Don't show progress bars.")
@click.option("-l", "--log-file", help="Save a verbose log to a file.", metavar="<filename>")
@click.pass_context
def nf_core_cli(ctx, verbose, no_header, hide_progress, log_file):
"""
nf-core/tools provides a set of helper tools for use with nf-core Nextflow pipelines.

It is designed for both end-users running pipelines and also developers creating new pipelines.
"""
if not no_header:
# print nf-core header if environment variable is not set
if os.environ.get("_NF_CORE_COMPLETE") is None:
# Print nf-core header
stderr.print(f"\n[green]{' ' * 42},--.[grey39]/[green],-.", highlight=False)
stderr.print("[blue] ___ __ __ __ ___ [green]/,-._.--~\\", highlight=False)
@@ -117,6 +101,22 @@ def nf_core_cli(ctx, verbose, no_header, hide_progress, log_file):
except Exception as e:
log.debug(f"Could not check latest version: {e}")
stderr.print("\n")
# Launch the click cli
nf_core_cli(auto_envvar_prefix="NFCORE")


@click.group(context_settings=dict(help_option_names=["-h", "--help"]))
@click.version_option(nf_core.__version__)
@click.option("-v", "--verbose", is_flag=True, default=False, help="Print verbose output to the console.")
@click.option("--hide-progress", is_flag=True, default=False, help="Don't show progress bars.")
@click.option("-l", "--log-file", help="Save a verbose log to a file.", metavar="<filename>")
@click.pass_context
def nf_core_cli(ctx, verbose, hide_progress, log_file):
"""
nf-core/tools provides a set of helper tools for use with nf-core Nextflow pipelines.

It is designed for both end-users running pipelines and also developers creating new pipelines.
"""
# Set the base logger to output DEBUG
log.setLevel(logging.DEBUG)