Skip to content

Add Fish Shell Completions#601

Open
gr1da wants to merge 6 commits intocreativeprojects:masterfrom
gr1da:master
Open

Add Fish Shell Completions#601
gr1da wants to merge 6 commits intocreativeprojects:masterfrom
gr1da:master

Conversation

@gr1da
Copy link

@gr1da gr1da commented Feb 6, 2026

Hi,
I had a go at creating a fish completion script. I modified the resticprofile complete command to output command descriptions which fish can use. I also added usage documentation.

@coderabbitai
Copy link

coderabbitai bot commented Feb 6, 2026

Walkthrough

Adds Fish shell completion: new --fish-completion flag and embedded Fish script, extends the completion generator to emit Fish output, and updates the completions core to support optional descriptions. Tests and documentation updated; a contrib Fish completion script was added.

Changes

Cohort / File(s) Summary
Command wiring & flags
commands.go, commands_generate.go
Added --fish-completion flag and go:embed of contrib/completion/fish-completion.fish; generation path for Fish returns embedded script.
Completion core
complete.go, complete_test.go
Added includeDescription bool field to Completer; changed NewCompleter(..., includeDescription) signature; formatting/matching updated to conditionally include descriptions; tests updated to pass the new flag.
Command tests
commands_test.go
Updated completer instantiation to new constructor signature and added a description-enabled completer instance for Fish expectations.
Fish completion script
contrib/completion/fish-completion.fish
New Fish completion handler implementing __resticprofile_completion and registering it via complete --command resticprofile --arguments "(__resticprofile_completion)".
Docs
docs/content/installation/shell.md, docs/content/configuration/getting_started/index.md
Documentation updated with Fish completion instructions and examples.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Shell as Fish shell
  participant CLI as resticprofile CLI
  participant Completer as Completer
  participant FS as Filesystem

  Shell->>CLI: invoke __resticprofile_completion -> run resticprofile complete --requester=fish --line/point
  CLI->>Completer: Complete(requester="fish", line, point)
  Completer->>Completer: format options with includeDescription=true
  Completer-->>CLI: return completions (with descriptions)
  CLI-->>Shell: print completions
  alt file completion needed
    CLI->>FS: request path completions
    FS-->>CLI: path candidates
    CLI-->>Shell: merged path completions
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add Fish Shell Completions' accurately and concisely summarizes the main change—adding fish shell completion support to resticprofile.
Description check ✅ Passed The description is directly related to the changeset, explaining that a fish completion script was created and the complete command was modified to output descriptions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@complete.go`:
- Around line 177-182: isOwnCommand fails to match when formatOwnCommand injects
a tab and description because it compares commandDef.name to the full formatted
string; update isOwnCommand to strip any tab-delimited description before
comparing (e.g. take substring before '\t' or split with
strings.SplitN(formatted, "\t", 2)[0]) so that comparisons against
commandDef.name work regardless of includeDescription; locate references in
toCompletionsWithProfilePrefix -> isOwnCommand and ensure the normalized
(name-only) value is used for the exact match against commandDef.name and any
subsequent logic.

In `@contrib/completion/fish-completion.fish`:
- Around line 65-75: In __resticprofile_completion the loop currently uses
"string match --regex '^[\r\n\t ]+$' -- \"$value\"; and return" which exits the
entire function when a whitespace-only completion is seen; change that to use
"and continue" so only the current iteration is skipped and previously
accumulated completions are preserved, and add the --quiet flag to string match
(i.e. "string match --quiet --regex '^[\r\n\t ]+$' -- \"$value\"; and continue")
to prevent matched whitespace from being printed as a spurious completion.

@gr1da gr1da marked this pull request as draft February 6, 2026 05:43
@gr1da gr1da marked this pull request as ready for review February 7, 2026 02:31
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.

1 participant