-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
exercism: install shell completions #369128
Merged
FliegendeWurst
merged 1 commit into
NixOS:master
from
kblcuk:exercism-install-shell-completions
Dec 29, 2024
Merged
exercism: install shell completions #369128
FliegendeWurst
merged 1 commit into
NixOS:master
from
kblcuk:exercism-install-shell-completions
Dec 29, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f27efb7
to
90af30d
Compare
90af30d
to
3836664
Compare
Exercism ships both with pre-generated completions [0], and has `completion` command to generate completions for bash/zsh/fish/powershell. Initially I was planning to use the latter, but seems like due to a bug (?) in cobra-generated completions (probably [1]), the resulting completions aren't fully working (if at all); so this makes use of the ones provided in the repo. I'll probably update this once more to use auto-generated completions once I manage to update cobra dependency for exercism CLI itself. [0] https://github.com/exercism/cli/tree/main/shell [1] spf13/cobra#1940
3836664
to
01f52b4
Compare
FliegendeWurst
approved these changes
Dec 29, 2024
kblcuk
added a commit
to kblcuk/cli
that referenced
this pull request
Dec 31, 2024
...so generated completions are for the end result built, not the current binary that we run. While the latter might make sense in some cases (maybe?), I'd think the end goal with completions is to produce them for the final result (so `exercism` command), not the intermediate binary that we're building. Judging by Cobra's docs [0] that's the intended usage here. Also the current approach produces unusable completions for fish shell, where function names can't have `/` in them. This can be observed by making a test build and trying to source the completion result in fish shell: ```fish go build -o testercism ./exercism/main.go ./testercism completion fish | source - (line 3): function: __./testercism_debug: invalid function name ... This also makes autogenerated completions usable in nix, where generation process would pass an absolute path to built binary when calling completions script [1]. As this repo auto-suggests, I also created a forum thread regarding this [2], but figured I might as well create a PR with possible solution. [0] https://pkg.go.dev/github.com/spf13/cobra#Command [1] NixOS/nixpkgs#369128 [2] https://forum.exercism.org/t/fish-shell-completion-generation-doesnt-always-work/14299
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
10.rebuild-darwin: 1-10
10.rebuild-linux: 1-10
12. first-time contribution
This PR is the author's first one; please be gentle!
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Exercism ships both with pre-generated completions [0], and has
completion
command to generate completions forbash/zsh/fish/powershell.
So this makes use of the latter and
installShellCompletion
.[0] https://github.com/exercism/cli/tree/main/shell