Commit 7520c7a
committed
Hard-code
...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/14299Use field in root cobra command1 parent 7580d02 commit 7520c7a
1 file changed
+2
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | 44 | | |
49 | | - | |
| 45 | + | |
50 | 46 | | |
51 | 47 | | |
52 | 48 | | |
| |||
0 commit comments