Skip to content
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

functions in fish shell completion auto-generated file should not contain "-" character #1121

Closed
umbynos opened this issue May 20, 2020 · 2 comments · Fixed by #1122
Closed

Comments

@umbynos
Copy link
Contributor

umbynos commented May 20, 2020

As asked by @marckhouzam here, I'm opening this issue.
I'm working on this PR and I noticed a problem with the auto-generated cobra completion file for fish shell: If the root command to complete contains a dash character in the name "-" (e.g. arduino-cli) the autocompletion will not work because of function naming (a function called __arduino-cli_comp_do_file_comp is created). For reference: fish-shell/fish-shell#1206

To fix this I simply replaced "-" with "_" here. But maybe it's better to fix this behaviour in cobra? Something like: if the command name contains a dash character automatically is replaced with an underscore.

@marckhouzam
Copy link
Collaborator

Thanks @umbynos.
I noticed that Cobra's bash completion was replacing : for commands.

name = strings.Replace(name, ":", "__", -1)

It does not affect Fish, but if the program has a : in the name (not a good idea, but supported), it would cause problems.

I will post a PR that replaces both - and : for fish completion.

@marckhouzam
Copy link
Collaborator

Fix in #1122

marckhouzam added a commit to VilledeMontreal/cobra that referenced this issue Jun 29, 2020
Fixes spf13#1121.
This is for programs that may contain a : or - in their name.

Signed-off-by: Marc Khouzam <[email protected]>
marckhouzam added a commit to VilledeMontreal/cobra that referenced this issue Jun 29, 2020
Fixes spf13#1121.
This is for programs that may contain a : or - in their name.

Signed-off-by: Marc Khouzam <[email protected]>
jharshman pushed a commit that referenced this issue Jul 10, 2020
Fixes #1121.
This is for programs that may contain a : or - in their name.

Signed-off-by: Marc Khouzam <[email protected]>
umbynos added a commit to arduino/arduino-cli that referenced this issue Aug 10, 2020
umbynos added a commit to arduino/arduino-cli that referenced this issue Aug 10, 2020
umbynos added a commit to arduino/arduino-cli that referenced this issue Aug 10, 2020
umbynos added a commit to arduino/arduino-cli that referenced this issue Aug 10, 2020
* update cobra to get new zsh completion spf13/cobra@2c5a0d3 and to fix this spf13/cobra@675ae5f

* add --no-descriptions also for zsh

* update docs

* update tests

* removed hack spf13/cobra#1121
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 a pull request may close this issue.

2 participants