Skip to content

add istioctl completions - #8343

Merged
krobelus merged 3 commits into
fish-shell:masterfrom
kfkonrad:feature/istioctl-completion
Oct 31, 2021
Merged

krobelus merged 3 commits into
fish-shell:masterfrom
kfkonrad:feature/istioctl-completion

Conversation

@kfkonrad

@kfkonrad kfkonrad commented Oct 12, 2021 •

Copy link
Copy Markdown
Contributor

Description

This PR adds completion for istioctl to fish. istioctl provides a command (istioctl completion fish) to generate the completion. My commit is that script verbatim. The script is fairly generic and not likely to change. It calls a "secret"/hidden subcommand of istioctl called istioctl __completion to generate the concrete completion results.

If you don't want to have this autogenerated script in your code base, my suggested alternative for istioctl.fish would be this:

if type -q "istioctl"
  istioctl completion fish | source
end

Let me know which one you prefer.

Fixes issue (no connected issue)

TODOs:

  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.rst

to replicate or update run
`istioctl completion fish > share/completions/istioctl.fish`
@kfkonrad
kfkonrad force-pushed the feature/istioctl-completion branch from 5e01246 to c3d6fc9 Compare October 12, 2021 08:39

@faho faho left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is going to need quite a bit of work before it's acceptable for inclusion in fish.

Mostly the debug and compatibility guff needs to be ripped out, and the completion refactored to avoid relying on an awkward global variable.

Consistency with fish is much much more important than consistency with other shells.

Comment thread share/completions/istioctl.fish Resolved
Comment thread share/completions/istioctl.fish Resolved
Comment thread share/completions/istioctl.fish Resolved
Comment thread share/completions/istioctl.fish Resolved
Comment thread share/completions/istioctl.fish Resolved
Comment thread share/completions/istioctl.fish Resolved
Comment thread share/completions/istioctl.fish Resolved
Comment thread share/completions/istioctl.fish Resolved
Comment thread share/completions/istioctl.fish Resolved
Comment thread share/completions/istioctl.fish Resolved
@krobelus

Copy link
Copy Markdown
Contributor

If you don't want to have this autogenerated script in your code base, my suggested alternative for istioctl.fish would be this:

if type -q "istioctl"
istioctl completion fish | source
end

yes please, let's do that instead.

The autogenerated script contains implementation details of cobra (things like shellCompDirectiveError) which might change with new Cobra versions (even if istioctl flags don't change).
We also don't need if type -q "istioctl" because fish will only load completions if it's executable.
So just add istioctl completion fish | source

Ideally, the istioctl will install its own /usr/share/fish/vendor_completions.d/istioctl.fish but go install doesn't really support that, so it's okay to include here.

@kfkonrad

Copy link
Copy Markdown
Contributor Author

Sorry, I didn't get around to doing this earlier. I've followed @krobelus's suggestion and switched over to the autogenerated completion. As they've explained this approach is probably more stable and requires no manual changes on generated code (and it's more future-proof)

@krobelus
krobelus merged commit 788692f into fish-shell:master Oct 31, 2021
@faho faho modified the milestones: fish-future, fish 3.4.0 Nov 2, 2021
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants