Fish shell completion generation doesn't always work

Ever since Polish up root command · exercism/cli@b78ccc2 · GitHub when Cobra’s Use field was changed to reference binary itself, fish shell completion generation (exercism completion fish) would produce unusable completion files. They are unusable because Cobra happens to utilise the value of Use field as part of the function, and if that contains slashes – function name becomes invalid.

This doesn’t seem to be causing problems in bash or zsh (?), at least recently that code was updated to properly reference binary name, but still having the same problem for fish shell.

If we really want for completion files to reference the particular binary name – perhaps it should at least use just the file name, not the full path? Otherwise maybe we still could just have Use: "exercism [command]", as Cobra’s doc itself seems to suggest .

I discovered this problem while looking at how to pre-generate completions for exercism in nix, where during build one could also generate completions, but that doesn’t currently work, since there we reference binary by it’s absolute path.

Happy to create a PR for this as well.

Since I can’t put more than 2 links in a post, here are the ones that were supposed to be in the original one:

Command reference: cobra package - github.com/spf13/cobra - Go Packages

How I originally found the problem: exercism: install shell completions by kblcuk · Pull Request #369128 · NixOS/nixpkgs · GitHub

Realised that this should’ve probably went to the “support” category, but oh well, all I really wanted to do is submit a pull request fixing a problem, not figure out yet another forum structure :person_shrugging:

1 Like

No worries, the discussion can always be organized later, if it is a problem here. The discord administrators/staff will do the needful, and may not necessarily do the wanted, until it becomes one of the needfuls.

We all just appreciate that you have contributed!

1 Like

For reference I also created a PR to CLI repo with potential fix (exercism/cli/pull/1186, somehow this doesn’t let me post links to github). PR got expectedly auto-closed, but hopefully this can move forward one way or another.

For your convenience.

Thanks for adding the link! For some reason my karma isn’t good enough for the local editor to allow links to github :smiling_face_with_tear:

1 Like