Skip to content

Added fish completions#2203

Closed
LunarEclipse363 wants to merge 1 commit into
samtools:developfrom
LunarEclipse363:develop
Closed

Added fish completions#2203
LunarEclipse363 wants to merge 1 commit into
samtools:developfrom
LunarEclipse363:develop

Conversation

@LunarEclipse363

Copy link
Copy Markdown
Contributor

Introduction

This PR adds comprehensive completions for use with the fish shell.

This includes:

  • finding all subcommands and their descriptions from the output of samtools
  • if python3 is available and samtools manpages are installed, generates comprehensive completions with descriptions for the subcommands
  • otherwise generates barebones completions for subcommands from the outputs of samtools help $subcommand (slightly better than the already provided bash completions)

I also added an entry in the changelog.

Demonstration of the full capabilities

image
image

Notes

I initially tried using the fallback approach as the primary one but after half a day of work realized that the samtools help outputs aren't consistent enough to write a regex to parse them reliably and which could extract all the data (all versions of each flag, what kind of value they take if any, descriptions).
Or if it can be done it's so complex I decided it's now worth it.
Doing that somewhat reasonably would require enforcing a strict style guide for help pages like "exactly one space between a flag and its value" and "at least two spaces between the flags/values and descriptions" and I feel like that's not feasible, so I went for extremely limited parsing in this regard and instead used a script bundled with fish to generate high quality completions from manpages (somehow this only worked well for the subcommands, not the main samtools command).

In any case, I'm quite happy with how this turned out and hope that I've fixed all the little bugs in it by now.

@jmarshall

jmarshall commented Apr 4, 2025

Copy link
Copy Markdown
Member

There's also bash completions already in misc/samtools_tab_completion (which the maintainers might consider renaming to misc/samtools_tab_completion.bash).

If installing this fish completion is added to make install then steps to install the bash completion should be added too. (Probably the destination is $(datarootdir)/bash-completion/completions but it's not super clear as this is a convention from bash-completion, not bash itself.)

However my suggestion might be to add this fish script to misc/ but continue to not install these completions in make install, instead leaving that to distribution packagers.

@vasudeva8

Copy link
Copy Markdown
Contributor

Thanks for the completion file, I have merged it.
We don't want to update the makefile, we leave it to the users.

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